/**
 * 锐鸥是一款免费开源的网页框架，由锐白个人开发，通过该程序用户可以快速创建网页应用。锐鸥追求的是轻巧的编程体验，让程序开发像鸥鸟般轻盈快活。使用方法：请将锐鸥(Ryo)的源码文件（如：ryo_v2025.8.1.0.js）下载放到目标网站的 js 目录，然后在 html 页面加载（如：＜script src="js/ryo_v2025.8.1.0.js"＞＜/script＞），在 body 标签后进行初始化即可（＜script＞window.onload = function() {ryo.init()};＜/script＞），锐鸥(Ryo)的初始化函数会在当前的 html 页面创建应用窗口界面。源码仓库：https://gitee.com/rybby/ryo
 * 
 * 版权所有 2025 梁业敏(字: 锐白) 保留所有权利。本软件采用 锐码署名传播许可证(RSPL) 授权。详情请见 锐码署名传播许可证 或 Rymaa Signature Propagation License 文件。| 网站: rymaa.cn | 邮箱: rybby@163.com
 */

var ryo = {
    // code info
    code: '锐鸥是一款免费开源的网页框架，由锐白个人开发，通过该程序用户可以快速创建网页应用。锐鸥追求的是轻巧的编程体验，让程序开发像鸥鸟般轻盈快活。使用方法：请将锐鸥(Ryo)的源码文件（如：ryo_v2025.8.1.0.js）下载放到目标网站的 js 目录，然后在 html 页面加载（如：＜script src="js/ryo_v2025.8.1.0.js"＞＜/script＞），在 body 标签后进行初始化即可（＜script＞window.onload = function() {ryo.init()};＜/script＞），锐鸥(Ryo)的初始化函数会在当前的 html 页面创建应用窗口界面。',

    // copyright info
    copr: '版权所有 2025 梁业敏(字: 锐白) 保留所有权利。本软件采用 锐码署名传播许可证(RSPL) 授权。详情请见 锐码署名传播许可证 或 Rymaa Signature Propagation License 文件。| 网站: rymaa.cn | 邮箱: rybby@163.com',
    
    // page obj
    pgobj: {},

    // init data
    ini: {
        ver: '2025.10.31.0',
        prefix: 'RYO_',
    },

    // global variable
    gv: {
        cvs: {}, // canvas
        snl: [], // show node list
        hpass: '', // hide pass
        ishide: 0, // is hide pass
        mapico: 'map1,map2,map3,map4,map5,map6,map7,map8,map9,map10,mapa,mapb,mapc,mapd,mape,mapf,mapg,maph,mapi,mapj,mapk,mapl,mapm,mapn,mapo,mapp,mapq,mapr,maps,mapt,pos,fav2,fav,like,home,sch,com,cul,cof,shop,comm,pla,talk,warn,fla,hot,dyna,user,shop2,comm2,appo',
        webp: 0,
        cpass: '3090b0a181cbe747c0f55e455b87dfe2', // content pass
        host: 'https://rymaa.cn',
    },

    // user data
    ud: {
        inv: '', // invite code
        ctp: 'h5_web', // client type

        // view mode(map(地图模式), olap(overlap重叠模式), fall(瀑布模式), icon(图标模式), tile(平铺模式), list(列表模式)), table(表格模式))
        vmod: 'list',
        gps: {
            type: 'IP', // 定位类型(IP, H5, SDK)
            lon: 116.4042, // 北京
            lat: 39.9151,
            ac2: '116.4042,39.9151',
            //lon: 121.4737, // 上海
            //lat: 31.2304,
            //ac2: '121.4737,31.2304',
            //lon: 108.3165, // 南宁
            //lat: 22.8108,
            //ac2: '108.3165,22.8108'
        },
    },

    // 导航菜单
    mnNav: "\
    .,\
        .n 导航\
        .m 导航菜单\
        .o 1\
        .dyna .,\
            .n 动态\
            .a ryo.gd('f`ld`tb`dyna`kw`ip.0')\
        ,.\
        .user .,\
            .n 用户\
            .a ryo.gd('f`ld`tb`user')\
        ,.\
        .spa .,\
            .n 空间\
            .m 快乐的家园\
            .o 1\
            .reg .,\
                .n 注册\
                .m 注册新账号\
                .a ryo.cmdv('reg 用户名 用户密码'); ryo.cmdf()\
            ,.\
            .lgn .,\
                .n 登录\
                .m 登录账号\
                .a ryo.cmdv('lgn 用户名 用户密码'); ryo.cmdf()\
            ,.\
            .lgt .,\
                .n 退出\
                .m 退出登录\
                .a ryo.req('f`lgt')\
            ,.\
            .des .,\
                .n 注销\
                .m 消除账号\
                .s 0\
            ,.\
            .pass .,\
                .n 找回\
                .m 找回密码\
                .a ryo.cmdv('ms .m f .v s .c 安全码(默认是初始密码) .n 新密码 .u 用户名'); ryo.cmdf()\
            ,.\
            .info .,\
                .n 资料\
                .a ryo.gd('f`ld`tb`user`kw`t.info`tpl`myinfo')\
            ,.\
        ,.\
        .help .,\
            .n 帮助\
            .m 平台知识大全\
            .v 1\
            .a ryo.gd('f`ld`tb`dyna`kw`ctp.1,ip.0`od`id.1')\
        ,.\
        .acti .,\
            .n 活动\
            .m 有你参与，无比惊喜\
            .v 1\
            .a ryo.gd('f`ld`tb`dyna`kw`ctp.2,ip.0`od`id.2')\
        ,.\
        .anno .,\
            .n 通告\
            .m 爆料，早看早知道\
            .v 1\
            .a ryo.gd('f`ld`tb`dyna`kw`ctp.3,ip.0`od`id.2')\
        ,.\
        .us .,\
            .n 关于我们\
            .m 平台相关资料介绍\
            .a ryo.gd('f`vd`tb`dyna`kw`uni._hgv13ky')\
        ,.\
        .code .,\
            .n 关于代码\
            .m 平台应用程序介绍\
            .a ryo.pop('关于程序代码', ryo.code)\
        ,.\
        .copr .,\
            .n 关于版权\
            .m 平台应用程序介绍\
            .a ryo.pop('关于程序版权', ryo.copr)\
        ,.\
    ,.",
    
    // 工具菜单
    mnTool: "\
    .,\
        .n 工具\
        .m 工具菜单\
        .o 1\
        .his .,\
            .n 历史\
            .s 0\
        ,.\
        .cut .,\
            .n 剪贴板\
            .s 0\
        ,.\
        .ava .,\
            .n 头像\
            .o 1\
            .fj .,\
                .n 风景\
                .a ryo.sel(this); ryo.ava('fj')\
            ,.\
            .kt .,\
                .n 卡通\
                .a ryo.sel(this); ryo.ava('kt')\
            ,.\
            .dw .,\
                .n 动物\
                .a ryo.sel(this); ryo.ava('dw')\
            ,.\
        ,.\
        .exp .,\
            .n 表情\
            .o 1\
            .dhg .,\
                .n 逗号哥\
                .a ryo.sel(this); ryo.exp('dhg')\
            ,.\
            .htg .,\
                .n 火炭哥\
                .a ryo.sel(this); ryo.exp('htg')\
            ,.\
            .mtg .,\
                .n 馒头哥\
                .a ryo.sel(this); ryo.exp('mtg')\
            ,.\
        ,.\
        .pic .,\
            .n 图片查看器\
            .s 0\
        ,.\
        .ado .,\
            .n 音频播放器\
            .s 0\
        ,.\
        .vdo .,\
            .n 视频播放器\
            .s 0\
        ,.\
        .file .,\
            .n 文件浏览器\
            .s 0\
        ,.\
        .up .,\
            .n 上传器\
            .s 0\
        ,.\
    ,.",

    // initialize, 初始化
    init: function(A) {
        var a, b, c, d, e, f, k, l, r, u, z, that = this;
        if (!A) {
            if (document) { // H5
                this.gv.MP = 0;
                if (document.body.offsetWidth < 400) {
                    document.body.className = 'H5WAP';
                    this.ud.ctp = 'h5_wap';
                } else {
                    document.body.className = '';
                    this.ud.ctp = 'h5_web';
                }
                window.addEventListener('resize', function() {
                    if (document.body.offsetWidth < 400) {
                        document.body.className = 'H5WAP';
                        this.ud.ctp = 'h5_wap';
                    } else {
                        document.body.className = '';
                        this.ud.ctp = 'h5_web';
                    }
                });
                if (document.createElement('canvas').toDataURL('image/webp').indexOf('data:image/webp') == 0) {
                    this.gv.webp = 1; // 该浏览器支持WebP格式的图片
                }
                a = new Image();
                a.src = '';
                a.onload = function() {
                    that.gv.avif = 1; // 该浏览器支持avif格式的图片
                };

                this.win();
                this.loading();
                this.mnhelp();
                this.gv.vw = document.body.offsetWidth;
                this.gv.vh = document.body.offsetHeight;
                //console.log(this.gv.vw, this.gv.vh);

                document.onmouseover = this.mi;
                document.onmousedown = this.md;
                document.onmousemove = this.mm;
                document.onmouseup = this.mu;
                document.onmouseout = this.mo;
                document.onclick = this.ck;
                document.oncontextmenu = this.mr;
                document.onkeydown = this.kd;
                document.onkeyup = this.ku;

            } else { // MP

                this.gv.MP = 1;
                if (WX) {
                    module.exports = {
                        ryo: ryo,
                    };
                }
                a = wx.getSystemInfoSync();
                this.gv.vw = a.windowWidth;
                this.gv.vh = a.windowHeight;
            }

            this.rbgi();
            //this.cvinit();
            //this.ls(1, 'c', '333', function(A) { console.log(A) });
            this.req('f`init');

        } else if (typeof A == 'object') {

            this.cd(A);
            this.stit();
            this.gv.url = a = document.referrer || document.location.href;
            this.gv.qp = this.gup(a); // query parameter
            a = a.split('//');
            a = (a[1] || '').split('/');
            b = (a[0] || '').split('.');
            c = a[a.length - 1] || '';
            t = c.substr(0, 1) || '';
            v = c.substr(1) || '';
            if (b.length < 3) this.gv.vu = this.gv.qp.uun || this.gv.qp.un || ''; // visit user
            else this.gv.vu = b[b.length - 3] || this.gv.qp.uun || this.gv.qp.un || '';
            this.inv(this.gv.vu);
            this.log(this.gv.url);

        }

        this.nmn('mnNav', 'MB');
        this.nmn('mnTool', 'TB');
    },

    // change data
    cd: function(A) {
        var z;
        if (typeof A == 'object') {
            if (A.ini) {
                for (z in A.ini) {
                    this.ini[z] = A.ini[z];
                }
            }
            if (A.ud) {
                for (z in A.ud) {
                    this.ud[z] = A.ud[z];
                }
            }
            if (A.gv) {
                for (z in A.gv) {
                    this.gv[z] = A.gv[z];
                }
            }

            if (A.ini && A.ini.prefix) this.ini.prefix = A.ini.prefix;
            if (A.ini && A.ini.lang) this.ls(this.ini.prefix + 'LG', A.ini.lang);
            if (A.ud && A.ud.cid) this.ls(this.ini.prefix + 'CID', A.ud.cid);
            if (A.ud && A.ud.ctag) this.ls(this.ini.prefix + 'CTAG', A.ud.ctag);
            if (A.ud && A.ud.ctp) this.gv.ctp = A.ud.ctp;
            if (A.ud && A.ud.un) this.ls(this.ini.prefix + 'userName', A.ud.un);
            else this.ls(this.ini.prefix + 'userName', '');
            if (A.cmd == 'reg' || A.cmd == 'lgn' || A.cmd == 'lgt') {
                this.nmn('mnNav.spa');
                this.sn('MB', 'n_');
            }
            this.cov();
        }
    },

    tctt: function(A) {
        var a, b, c, d, s, z;
        s = [];
        a = (A || '').split(/, */);
        for (z = 0; z < a.length; z++) {
            if (!a[z]) continue;
            s.push('<img class="tcPic" src="' + a[z] + '" />');
        }
        s = s.join('');
        document.body.innerHTML = '<i class="tcBox"><i class="tcList">' + s + '<i class="cf"></i></i></i>';
    },

    win: function(A) {
        var a, b, c, d;
        document.body.innerHTML = '<i id="TMP" style="display:none;"></i><i id="IB" style="display:none;"></i><i id="VB"><i id="CTN"><i id="CTT"><i id="LB"></i></i><i id="MB"><i class="mnLab"><i class="ico30 mnNav" onclick="ryo.ws(\'MB\', 1)"></i><i class="ico30 mnBack"></i><i class="mnName"></i></i><i class="mnList"></i></i><i id="FW" class="n_ h_"><i id="fwCtn"><i id="fwCtt"></i><i id="fwBtn"><i class="ico30 icoWs" onclick="ryo.ws(\'FW\', 3)"></i><i class="ico30 icoX" onclick="ryo.hn(\'FW\')"></i></i></i></i><i id="EB"><textarea id="CMD" onfocus="ryo.cmdf()" onblur="ryo.cmdb()" oninput="ryo.cmdi()" placeholder="?"></textarea><i id="cmdIco"><i class="ico30 cmdLink" onclick="ryo.tet(\'?u\')"></i><i class="ico30 cmdExp" onclick="ryo.nmn(\'mnTool.exp\', \'TB\'); ryo.sn(\'TB\', \'n_\')"></i><i class="ico30 cmdPic"></i><i class="ico30 cmdAdo"></i><i class="ico30 cmdVdo"></i><i class="ico30 cmdFile"></i></i><i class="ico30 icoCmdS" onclick="ryo.cmd(ryo.gv.cmd.value);"></i><i class="ico30 icoCmdWs" onclick="ryo.ws(\'EB\', 4)"></i></i><i id="TB"><i class="mnLab"><i class="ico30 mnTool" onclick="ryo.ws(\'TB\', 1)"></i><i class="ico30 mnBack"></i><i class="mnName"></i></i><i class="mnList"></i></i><i id="MSG" class="i_" onmouseover="ryo.sn(this, \'n_\')" onmouseout="ryo.hn(this, \'i_\')"></i><i id="POP" class="i_ h_" mn="1"><i id="popCtt"></i><i id="popLab"></i><i id="popBtn"><i class="ico30 icoWs" onclick="ryo.ws(\'POP\', 3)"></i><i class="ico30 icoX" onclick="ryo.hn(\'POP\')"></i></i></i></i><canvas id="CVS" class="h_" style="opacity:1; position:absolute; left:0px; top:0px; width:100%; height:100%;"></canvas></i>';
        this.gv.tmp = this.gn('TMP');
        this.gv.lb = this.gn('LB');
        this.gv.cmd = this.gn('CMD');
    },

    // show menu help
    mnhelp: function(A) {
        var a, b, c, d;
        a = this.ls('mnHelp') || 0;
        if (a > 3) return;
        b = '<i style="width: 100%; text-align: center;"><img style="width: 100%; max-width: 100%;" src="img/sys/menuHelp.jpg"><i style="width: 80px; height: 30px; line-height: 30px; margin: 10px auto;" class="btn" onclick="var a = parseInt(ryo.ls(\'mnHelp\')) || 0; a++; ryo.ls(\'mnHelp\', a); ryo.hn(\'POP\'); ryo.se()">知道了</i></i></i>';
        this.pop('网页操作帮助教程', b, 'n_');
    },

    // cover
    cov: function(A) {
        var a, b, c, d, l, o, s, z;
        o = this.ini.lang.mnNav;
        s = [];
        l = 2;
        for (z in o) {
            if (typeof o[z] != 'object') continue;
            if (o[z]['s'] == 0) continue;
            if (o[z]['v'] == 1) {
                a = ' title="' + (o[z]['m'] || o[z]['n'] || '') + '" onclick="' + (o[z]['a'] || '') + '"'; // action
                b = this.rbgc();
                if (l == 2) {
                    l = 1;
                    s.push('<i class="cover_' + l + '"><i style="' + b + '" class="covM"' + a + '>' + (o[z]['m'] || '') + '</i><i style="' + b + '" class="covN"' + a + '>' + (o[z]['n'] || '') + '</i></i>');
                } else {
                    l = 2;
                    s.push('<i class="cover_' + l + '"><i style="' + b + '" class="covN"' + a + '>' + (o[z]['n'] || '') + '</i><i style="' + b + '" class="covM"' + a + '>' + (o[z]['m'] || '') + '</i></i>');
                }
            }
        }
        s = s.join('');
        this.gv.lb.innerHTML = '<i class="covBox">' + s + '</i>';
    },

    // new menu
    nmn: function(A, B, C) {
        var a, b, c, d, e, f, l, m, n, o, p, s, t, y, z, sel, back, menu;
        t = this.dt();
        cov = [];
        menu = {
            mnNav: this.obj(this.mnNav),
            mnTool: this.obj(this.mnTool),
            mnSel: this.obj(this.mnSel)
        };
        o = this.ini.lang || menu;
        A = A || 'mnNav';
        B = B || 'MB';
        a = A.split('.');
        m = a[a.length - 1];
        for (z = 0; z < a.length; z++) {
            if (o[a[z]]) o = o[a[z]];
        }
        if (a.length > 1) a.pop();
        b = a.join('.');

        if (A == 'mnNav') {
            back = 'ryo.cov()';
        } else {
            back = 'ryo.nmn(\'' + b + '\', \'' + B + '\')';
        }

        s = [];
        l = 1;
        n = this.ud.un || this.ls(this.ini.prefix + 'userName') || '';
        for (z in o) {
            if (z == 'n' || z == 'm') continue;
            if (z == 'c') {
                sel = o[z];
                continue;
            }
            if (typeof o[z] == 'object') {
                if (o[z]['s'] == 0) continue;
                if (m == 'spa') {
                    if (n && (z == 'reg' || z == 'lgn' || z == 'pass')) continue;
                    else if (!n && z != 'reg' && z != 'lgn' && z != 'pass') continue;
                }
                a = '" onclick="ryo.sel(this); ' + (o[z]['a'] || ''); // action
                if (o[z]['o'] == 1) { // have child obj
                    a += '; ryo.nmn(\'' + (A + '.' + z) + '\', \'' + B + '\')';
                }
                //console.log(a);

                if ((C && C == z) || sel == z) c = ' s_';
                else c = '';
                s.push('<i class="btn tr_' + l + c + '" title="' + (o[z]['m'] || o[z]['n'] || '') + a + '">' + (o[z]['n'] || '') + '</i>');
                if (l == 1) l = 2;
                else l = 1;
            }
        }
        if (m == 'ava' || m == 'exp') s.push('<i id="aePic"></i>');
        s.push('<i class="cf"></i>');
        s = s.join('');
        p = this.gn(B);
        n = p.lastChild;
        if (n) n.innerHTML = s;
        n = p.firstChild.lastChild;
        //console.log(o, n);
        if (n) {
            this.nt(n, o['n'] || '');
            this.na(n, 'title', o['m'] || o['n'] || '');
        }
        n = p.firstChild.firstChild.nextSibling;
        if (o['n'] == '') d = this.cov();
        if (n) this.na(n, 'onclick', back);
    },

    // pop window
    pop: function(A, B, C) {
        var a, b, c, d;
        C = C || 'i_';
        a = this.gn('popLab');
        b = this.gn('popCtt');
        if (A && a) a.innerHTML = A;
        if (B && b) b.innerHTML = B;
        this.sn('POP', C);
    },

    // new qr code
    nqr: function(A) {
        var a, b, c, d, s, cvs, ctx, img, that;
        that = this;
        A = this.gn(A);
        a = this.na(A, 'un') || 'userName';
        b = this.na(A, 'ava') || 'img/qri/user.jpg';
        c = this.na(A, 'qr') || '';
        d = this.na(A, 'bgi') || 'img/qri/qr-420x750-team-1.jpg';
        //console.log(A, a, b, c, d);

        cvs = document.createElement('canvas');
        ctx = cvs.getContext('2d');
        cvs.width = 420;
        cvs.height = 750;
        img = new Image();
        img.src = d;
        img.onload = function() {
            ctx.drawImage(img, 0, 0, 420, 750);
            img = new Image();
            img.src = b;
            img.onload = function() {
                ctx.drawImage(img, 10, 640, 100, 100);
                ctx.fillStyle = '#000';
                ctx.font = '24px Verdana';
                ctx.textBaseline = 'top';
                ctx.fillText(a, 178, 645);
                img = new Image();
                img.src = c;
                img.onload = function() {
                    ctx.drawImage(img, 310, 640, 100, 100);
                    s = cvs.toDataURL('image/jpeg', 0.9);
                    A.onload = null;
                    A.src = s;
                }
            }
        }
    },

    // avatar
    ava: function(A) {
        var a, b, c, d, n, s, z;
        A = A || 'fj';
        s = [];
        for (z = 0; z < 50; z++) {
            a = z + 1;
            b = 'img/ava/' + A + '/' + (A + a) + '.jpg';
            c = '0' + A + a;
            s.push('<img class="avaList" src="' + b + '" onclick="ryo.gv.tmpAva = \'' + c + '\'; var a, b, c, d; a = ryo.gn(\'user_ava\'); if(a) a.src = \'' + b + '\'; b = ryo.gn(\'user_avaVal\'); if(b) {b.value = \'' + c + '\'; b.setAttribute(\'is\', \'cg\'); c = b.parentNode; d = c.className; d = d.replace(/ *e_/g, \'\'); c.className = d + \' e_\'}" />');
        }
        s = s.join('');
        //console.log(s);
        n = this.gn('aePic');
        if (n) n.innerHTML = s;
    },

    // expression
    exp: function(A) {
        var a, b, c, d, n, o, s, z;
        A = A || 'dhg';
        o = {
            'dhg': [
                ['dwx', '微笑'],
                ['dwy', '无语'],
                ['dcj', '吃惊'],
                ['dhx', '坏笑'],
                ['dku', '酷'],
                ['dxm', '羡慕'],
                ['dam', '爱慕'],
                ['dty', '头晕'],
                ['dxiu', '羞'],
                ['dwq', '委屈'],
                ['dsx', '桑心'],
                ['dfd', '奋斗'],
                ['dgl', '鬼脸'],
                ['dyw', '疑问'],
                ['dbz', '闭嘴'],
                ['dhan', '汗'],
                ['dtg', '听歌'],
                ['dsj', '碎觉'],
                ['dsq', '生气'],
                ['dhei', '黑']
            ],

            'htg': [
                ['hwx', '微笑'],
                ['hhx', '坏笑'],
                ['hkp', '可怕'],
                ['hyx', '淫笑'],
                ['hbm', '报名'],
                ['hkx', '苦笑'],
                ['hbx', '爆笑'],
                ['hdx', '大笑'],
                ['hxy', '小样'],
                ['ho', '哦'],
                ['hgl', '鬼脸'],
                ['hlh', '脸红'],
                ['hxiu', '羞'],
                ['hcj', '吃惊'],
                ['hje', '惊愕'],
                ['htx', '投降'],
                ['hdk', '大哭'],
                ['hfc', '发财'],
                ['hfn', '发怒'],
                ['hhy', '坏银']
            ],

            'mtg': [
                ['mkx', '开心'],
                ['mxx', '嘻嘻'],
                ['mhx', '坏笑'],
                ['mdx', '大笑'],
                ['mbx', '爆笑'],
                ['mje', '惊愕'],
                ['mbn', '暴怒'],
                ['mfn', '发怒'],
                ['mdk', '大哭'],
                ['msx', '桑心'],
                ['mky', '哭晕'],
                ['mjg', '警告'],
                ['mws', '无视'],
                ['mwy', '无语'],
                ['mwq', '委屈'],
                ['mhan', '汗'],
                ['mam', '爱慕'],
                ['mxiu', '羞'],
                ['msj', '碎觉'],
                ['myw', '疑问']
            ]
        };
        s = [];
        for (z = 0; z < o[A].length; z++) {
            a = z + 1;
            b = 'img/exp/' + A + '/' + o[A][z][0] + '.png';
            s.push('<i class="expList" onclick="ryo.tet(\'?e\', \'' + o[A][z][0] + '\')"><img class="expImg" src="' + b + '" /><i class="expTxt">' + o[A][z][0] + ' ' + o[A][z][1] + '</i></i>');
        }
        s = s.join('');
        //console.log(s);
        n = this.gn('aePic');
        if (n) n.innerHTML = s;
    },

    // get invite code
    inv: function(A) {
        var a = this.ls(this.ini.prefix + 'INVITE');
        if (a) this.ud.inv = a;
        else if (A) {
            this.ls(this.ini.prefix + 'INVITE', A);
            this.ud.inv = A;
        } else {
            this.ud.inv = '';
        }
    },

    // get url parameter
    gup: function(A) {
        var a, b, c, d, z;
        //console.log('gup', A);
        if (typeof A == 'object') {
            if (A.scene) A = A.scene;
            else return A;
        }
        a = decodeURIComponent(A || '');
        b = a.indexOf('?');
        if (b != -1) a = a.substr(b + 1);
        a = a.split('&');
        b = {};
        for (z = 0; z < a.length; z++) {
            c = (a[z] || '').split('=');
            if (c[0]) b[c[0]] = c[1];
        }
        //console.log('gup', b);
        return b;
    },

    // set title
    stit: function(A) {
        var a, b, c, d, n;
        n = this.gn('TIT');
        if (!n) return;
        s = n.innerHTML || '';
        a = this.ini.st || '';
        b = (this.ini.sn || '') + (this.ini.sd || '');
        c = a && b ? a + ' - ' + b : a ? a : '';
        if (c) n.innerHTML = c;
    },

    err: function(A, B) {
        return { EC: A, EM: B };
    },

    // loading
    loading: function(A) {
        A = A || 'LB';
        A = this.gn(A);
        if (A) A.innerHTML = '<i class="imgLoad"><img src="img/sys/loading.gif" /></i>';
    },

    obj: function(A, B, C, D) {
        var a, b, c, d, l, s, k, v, o, z;
        A = A || '';
        B = B || 1;
        C = C || '`';
        D = D || 0;
        if (B == 1) {
            if (typeof A == 'object') return A;
            if (!A || typeof A != 'string') return null;
            A = A.trim();
            a = A.substr(0, 2);
            if (a == '{"') return JSON.parse(A);
            if (a == '.,') return this.stc(A);
            a = A.split(C);
            l = a.length;
            o = {};
            for (z = 0; z < l; z += 2) {
                k = this.e36(a[z], 2);
                v = this.e36(a[z + 1], 2);
                if (!k) continue;
                o[k] = v;
            }
            return o;

        } else {

            if (typeof A == 'string') return A;
            if (typeof A == 'number') return A + '';
            if (!A || typeof A != 'object') return '';
            if (typeof A == 'object' && C == 1) return JSON.stringify(A);
            if (typeof A == 'object' && C == 2) return this.cts(A, D);
            s = [];
            for (z in A) {
                s.push(this.e36(z, 1), this.e36(A[z], 1));
            }
            s = s.join(C);
            return s;
        }
    },

    // comma period obj
    cpo: function(A, B=1, C=0) {
        if(B == 1) return this.stc(A);
        return this.cts(A, C);
    },

    // string to cpo(comma period obj)
    stc: function(str) {
        var i = 0;
        var len = str.length;

        function skipWhitespace() {
            while (i < len && ' \t\n\r'.indexOf(str.charAt(i)) !== -1) i++;
        }

        function parseValue() {
            skipWhitespace();
            if (i >= len) return undefined;

            // 数组开始 ..,
            if (str.substr(i, 3) === '..,') {
                i += 3;
                return parseArray();
            }

            // 对象开始 .,
            if (str.substr(i, 2) === '.,') {
                i += 2;
                return parseObject();
            }

            // 普通值
            var start = i;
            while (i < len) {
                var char = str.charAt(i);
                
                // 只有在遇到新的键开始时才结束（空格 + . + 非分隔符）
                if (char === ' ' || char === '\t' || char === '\n' || char === '\r') {
                    // 检查后面是否是新的键开始：空格后紧跟 . 且 . 后不是分隔符
                    var j = i;
                    while (j < len && ' \t\n\r'.indexOf(str.charAt(j)) !== -1) j++;
                    if (j < len && str.charAt(j) === '.' && 
                        j + 1 < len && ' .,\t\n\r'.indexOf(str.charAt(j + 1)) === -1) {
                        break; // 遇到新的键，结束当前值
                    }
                }
                
                // 遇到对象结束或数组结束
                if (str.substr(i, 2) === ',.' || str.substr(i, 3) === ',,.') {
                    break;
                }
                
                i++;
            }
            
            var val = str.substring(start, i).trim();

            // 类型还原
            if (val === 'TRUE') return true;
            if (val === 'FALSE') return false;
            if (val === 'NULL') return null;
            if (val === 'EMPTY' || val === '') return '';

            // 尝试转数字
            if (/^-?\d+$/.test(val)) {
                return parseInt(val, 10);
            }
            if (/^-?\d*\.\d+$/.test(val)) {
                return parseFloat(val);
            }

            return val;
        }

        function parseObject() {
            var obj = {};
            skipWhitespace();

            while (i < len) {
                skipWhitespace();
                if (i >= len) break;

                // 检查对象结束标志 ',.'
                if (str.substr(i, 2) === ',.') {
                    i += 2;
                    return obj;
                }

                // 必须是 '.' 开头，且 '.' 前必须是空白或起始位置
                if (str.charAt(i) !== '.') {
                    i++;
                    continue;
                }

                // 检查 '.' 前是否为空白或起始位置
                if (i > 0 && ' \t\n\r'.indexOf(str.charAt(i - 1)) === -1) {
                    // 前面不是空白，说明是如 abc.key 中的 '.'，不是键名
                    i++;
                    continue;
                }

                i++; // 跳过 '.'

                // 关键：不允许 . 和 key 之间有空格
                // 检查是否已到结尾或下一个字符是分隔符（即 key 为空）
                if (i >= len || ' .,\t\n\r'.indexOf(str.charAt(i)) !== -1) {
                    // key 为空，跳过
                    continue;
                }

                // 提取 key 名称：连续非空白、非分隔符
                var start = i;
                while (i < len && ' .,\t\n\r'.indexOf(str.charAt(i)) === -1) {
                    i++;
                }
                var key = str.substring(start, i);
                if (!key) continue;

                // 此时 i 指向 key 后的第一个分隔符（空格、.、, 等）
                skipWhitespace(); // 跳过 key 后的空白
                if (i >= len) break;

                // 解析值
                var value;
                if (str.substr(i, 3) === '..,') {
                    i += 3;
                    value = parseArray();
                } else if (str.substr(i, 2) === '.,') {
                    i += 2;
                    value = parseObject();
                } else {
                    value = parseValue();
                }

                obj[key] = value;
                skipWhitespace();
            }

            return obj;
        }

        function parseArray() {
            var arr = [];
            var itemStart = i;
            skipWhitespace();

            while (i < len) {
                skipWhitespace();
                if (i >= len) break;

                if (str.substr(i, 3) === ',,.') {
                    var item = str.substring(itemStart, i).trim();
                    if (item) arr.push(parsePrimitive(item));
                    i += 3;
                    return arr;
                }

                if (str.charAt(i) === ',') {
                    var item = str.substring(itemStart, i).trim();
                    if (item) arr.push(parsePrimitive(item));
                    i++;
                    skipWhitespace();
                    itemStart = i;
                    continue;
                }
                i++;
            }

            var item = str.substring(itemStart).trim();
            if (item) arr.push(parsePrimitive(item));
            return arr;
        }

        // 提取基础类型
        function parsePrimitive(val) {
            val = val.trim();
            if (val === 'TRUE') return true;
            if (val === 'FALSE') return false;
            if (val === 'NULL') return null;
            if (val === 'EMPTY' || val === '') return '';
            if (/^-?\d+$/.test(val)) return parseInt(val, 10);
            if (/^-?\d*\.\d+$/.test(val)) return parseFloat(val);
            return val;
        }

        skipWhitespace();
        if (str.substr(i, 2) === '.,') {
            i += 2;
            return parseObject();
        }

        return {};
    },

    // cpo(comma period obj) to string
    cts: function(obj, indent=0) {
        var a, l, n, k, v, that = this;
        l = 0;
        indent = parseInt(indent);
        n = indent ? '\n' : ' ';
        function arr2str(A, B=0, C=' ') {
            var a, e, l, n, k, v, z;
            a = [];
            l = B;
            n = C;
            for(z = 0; z < A.length; z++) {
                v = A[z];
                t = typeof v;
                if(t == 'function') continue;
                else if(Array.isArray(v)) {
                    a.push(that.pc(' ', (l+1)*indent) +'.'+k+' ..,');
                    s = arr2str(v, l+1, n) + n + that.pc(' ', (l+1)*indent) + ',,.';
                    a.push(s);
                } else if(t == 'object') {
                    a.push(that.pc(' ', (l+1)*indent) +'.'+k+' .,');
                    s = obj2str(v, l+1, n) + n + that.pc(' ', (l+1)*indent) + ',.';
                    a.push(s);
                } else {
                    if(v == null) v = 'NULL';
                    else if(t == 'string' && !v) v = 'EMPTY';
                    else if(t == 'boolean') v = v? 'TRUE' : 'FALSE';
                    if(z < A.length-1) e = ', ';
                    else e = '';
                    a.push(that.pc(' ', (l+1)*indent) +v+e);
                }
            }
            a = a.join(n);
            return a;
        }
        
        function obj2str(A, B=0, C=' ') {
            var a, l, n, k, v;
            a = [];
            l = B;
            n = C;
            for(k in A) {
                v = A[k];
                t = typeof v;
                if(t == 'function') continue;
                else if(Array.isArray(v)) {
                    a.push(that.pc(' ', (l+1)*indent) +'.'+k+' ..,');
                    s = arr2str(v, l+1, n) + n + that.pc(' ', (l+1)*indent) + ',,.';
                    a.push(s);
                } else if(t == 'object') {
                    a.push(that.pc(' ', (l+1)*indent) +'.'+k+' .,');
                    s = obj2str(v, l+1, n) + n + that.pc(' ', (l+1)*indent) + ',.';
                    a.push(s);
                } else {
                    if(v == null) v = 'NULL';
                    else if(t == 'string' && !v) v = 'EMPTY';
                    else if(t == 'boolean') v = v? 'TRUE' : 'FALSE';
                    a.push(that.pc(' ', (l+1)*indent) +'.'+k+' ' + v);
                }
            }
            a = a.join(n);
            return a;
        }

        var str = '.,' +n+ obj2str(obj, 0, n) + n + that.pc(' ', l*indent) + ',.';
        return str;
    },

    // rand range, 随机范围
    rr: function(A) {
        var a, b, c, d, e, f;
        A += '';
        a = (A || '0-1').split(/ *[\,\-] */);
        if (a.length < 2) return a[0];
        b = parseFloat(a[0]) || 0;
        c = parseFloat(a[1]) || 1;
        e = Math.min(b, c);
        f = Math.max(b, c);
        return Math.random() * (f - e) + e;
    },

    // rand string, 随机字串
    rs: function(A, B) {
        var a, b, c, d, l, s, z;
        A = A || 6;
        B = B || 'nlu';
        a = '0123456789';
        b = 'abcdefghijklmnopqrstuvwxyz';
        c = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
        d = '';
        s = '';
        if (B.indexOf('n') != -1) s += a;
        if (B.indexOf('l') != -1) s += b;
        if (B.indexOf('u') != -1) s += c;
        s = s.split('');
        l = s.length;
        for (z = 0; z < A; z++) {
            d += s[Math.floor(Math.random() * l)];
        }
        return d;
    },

    // rand background color
    rbgc: function(A, B, C, D) {
        var a, b, c, d;
        A = A + '' || '150-250';
        B = B + '' || '150-250';
        C = C + '' || '150-250';
        D = parseFloat(D) || .85;
        a = A.split('-');
        b = B.split('-');
        c = C.split('-');

        a[0] = parseFloat(a[0]) || 150;
        a[1] = parseFloat(a[1]) || 250;
        a[0] = Math.min(a[0], a[1]);
        a[1] = Math.max(a[0], a[1]);
        a = Math.floor(Math.random() * (a[1] - a[0]) + a[0]);

        b[0] = parseFloat(b[0]) || 150;
        b[1] = parseFloat(b[1]) || 250;
        b[0] = Math.min(b[0], b[1]);
        b[1] = Math.max(b[0], b[1]);
        b = Math.floor(Math.random() * (b[1] - b[0]) + b[0]);

        c[0] = parseFloat(c[0]) || 150;
        c[1] = parseFloat(c[1]) || 250;
        c[0] = Math.min(c[0], c[1]);
        c[1] = Math.max(c[0], c[1]);
        c = Math.floor(Math.random() * (c[1] - c[0]) + c[0]);

        return 'background-color: rgba(' + a + ', ' + b + ', ' + c + ', ' + D + ');';
    },

    // rand background image
    rbgi: function(A) {
        var a, b, c, d, i;
        A = A || 1;
        a = Math.floor(this.rr('1-5'));
        if (this.ud.ctp == 'h5_web' || this.ud.ctp == 'h5_wap') b = '';
        else b = this.gv.host + '/';
        c = b + 'img/bgi/bg-' + a + '-' + (this.ud.ctp == 'h5_web' ? 1 : 2) + '.jpg';
        i = "background-image: url('" + c + "'); background-size: 100% 100%;";
        if (A == 1) {
            if (document.body) {
                document.body.setAttribute('style', i);
            } else if (WX) {
                this.pgobj.setData({
                    pgbgi: i
                });
            }
        } else if (A == 2) {

        }
        return i;
    },

    // pad char
    pc: function(A='', B=0) {
        var s = '', z;
        for(z = 0; z < B; z++) {
            s += A;
        }
        return s;
    },

    // exclamation encode or decode 36 special symbols
    e36: function(A, B) {
        // !@#$%^&*()-_=+`~[]{}\|;:'",.<>/? trn;
        // 1234567890abcdefghijklmnopqrstuvwxyz;
        var a, b, c, d, e, f, l, y, z;
        if (!A) return '';
        A += '';
        B = B || 1;
        a = '!@#$%^&*()-_=+`~[]{}\\|;:\'",.<>/? \t\r\n';
        b = '1234567890abcdefghijklmnopqrstuvwxyz';
        a = a.split('');
        b = b.split('');
        c = {};
        for (z = 0; z < 36; z++) {
            b[z] = '!' + b[z];
            c[a[z]] = b[z];
        }
        l = a.length;
        if (B == 1) {
            A = A.replace(/\!/g, ':E:');
            for (z in c) {
                A = A.split(z);
                A = A.join(c[z]);
            }
        } else {
            while(1) {
                for (z = 0; z < l; z++) {
                    A = A.split(b[z]);
                    A = A.join(a[z]);
                }
                if(A.indexOf('!') < 0) break;
            }
            A = A.replace(/\:E\:/g, '!');
        }
        return A;
    },

    // base64 decode or encode
    b64: function(A, B, C) {
        var a, b, c, d, e, f, g, h, i, j, k, o, p, s, z;
        B = B || 1;
        if (A == '') return A;
        if (!C) {
            if (B == 1) {
                a = b64_encode(b64_u16u8(A));
                a = a.replace(/\+/g, '-');
                a = a.replace(/\//g, '_');
                return a
            } else {
                a = A;
                a = a.replace(/\-/g, '+');
                a = a.replace(/\_/g, '/');
                a = b64_u8u16(b64_decode(a));
                return a
            }
        } else if (C == 1) {
            p = this.gv.cpass;
            if (!p) C = '3090b0a181cbe747c0f55e455b87dfe2';
            else C = p
        }
        if (B == 1) {
            a = [];
            b = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
            for (z = 0; z < 6; z++) {
                a.push(b[Math.floor(Math.random() * 10)])
            }
            a = a.join('');
            A = b64_u16u8(A)
        } else {
            a = A.substr(0, 6);
            A = A.substr(6);
            A = A.replace(/\-/g, '+');
            A = A.replace(/\_/g, '/');
            A = b64_decode(A)
        }
        b = '';
        l = C.length;
        for (z = 0; z < l; z++) {
            b += C.charAt(z);
            if (z < 6) b += a.charAt(z)
        }
        if (z < 6) b += a.substr(z);
        l = b.length;
        c = [];
        for (z = 0; z < 256; z++) c.push(b.charCodeAt(z % l));
        l = c.length;
        m = A.length;
        d = [];
        for (z = 0, y = 0; z < m; z++, y++) {
            if (y >= l) y = 0;
            if (B == 1) e = A.charCodeAt(z) ^ c[y];
            else e = c[y] ^ A.charCodeAt(z);
            d.push(String.fromCharCode(e))
        }
        d = d.join('');
        if (B == 1) {
            d = b64_encode(d);
            d = d.replace(/\+/g, '-');
            d = d.replace(/\//g, '_');
            return a + '' + d
        } else {
            return b64_u8u16(d)
        }

        function b64_u16u8(A) {
            var a, b, c, d;
            a = '';
            c = A.length;
            for (b = 0; b < c; b++) {
                d = A.charCodeAt(b);
                if ((d >= 0x0001) && (d <= 0x007F)) {
                    a += A.charAt(b)
                } else if (d > 0x07FF) {
                    a += String.fromCharCode(0xE0 | ((d >> 12) & 0x0F));
                    a += String.fromCharCode(0x80 | ((d >> 6) & 0x3F));
                    a += String.fromCharCode(0x80 | ((d >> 0) & 0x3F))
                } else {
                    a += String.fromCharCode(0xC0 | ((d >> 6) & 0x1F));
                    a += String.fromCharCode(0x80 | ((d >> 0) & 0x3F))
                }
            }
            return a
        }

        function b64_u8u16(A) {
            var a, b, c, d, e, f;
            a = '';
            c = A.length;
            b = 0;
            while (b < c) {
                d = A.charCodeAt(b++);
                switch (d >> 4) {
                    case 0:
                    case 1:
                    case 2:
                    case 3:
                    case 4:
                    case 5:
                    case 6:
                    case 7:
                        a += A.charAt(b - 1);
                        break;
                    case 12:
                    case 13:
                        e = A.charCodeAt(b++);
                        a += String.fromCharCode(((d & 0x1F) << 6) | (e & 0x3F));
                        break;
                    case 14:
                        e = A.charCodeAt(b++);
                        f = A.charCodeAt(b++);
                        a += String.fromCharCode(((d & 0x0F) << 12) | ((e & 0x3F) << 6) | ((f & 0x3F) << 0));
                        break
                }
            }
            return a
        }

        function b64_encode(A) {
            var a, b, c, d, e, f, g, h, i, j, k, o, s, z;
            o = '';
            s = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
            h = 0;
            do {
                a = A.charCodeAt(h++);
                b = A.charCodeAt(h++);
                c = A.charCodeAt(h++);
                d = a >> 2;
                e = ((a & 3) << 4) | (b >> 4);
                f = ((b & 15) << 2) | (c >> 6);
                g = c & 63;
                if (isNaN(b)) {
                    f = g = 64
                } else if (isNaN(c)) {
                    g = 64
                }
                o = o + s.charAt(d) + s.charAt(e) + s.charAt(f) + s.charAt(g);
                a = b = c = '';
                d = e = f = g = ''
            } while (h < A.length);
            return o
        }

        function b64_decode(A) {
            var a, b, c, d, e, f, g, h, i, j, k, o, s, z;
            o = '';
            s = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
            h = 0;
            if (A.length % 4 != 0) {
                return ''
            }
            i = /[^A-Za-z0-9\+\/\=]/g;
            if (i.exec(A)) {
                return ''
            }
            do {
                d = s.indexOf(A.charAt(h++));
                e = s.indexOf(A.charAt(h++));
                f = s.indexOf(A.charAt(h++));
                g = s.indexOf(A.charAt(h++));
                a = (d << 2) | (e >> 4);
                b = ((e & 15) << 4) | (f >> 2);
                c = ((f & 3) << 6) | g;
                o = o + String.fromCharCode(a);
                if (f != 64) {
                    o += String.fromCharCode(b)
                }
                if (g != 64) {
                    o += String.fromCharCode(c)
                }
                a = b = c = '';
                d = e = f = g = ''
            } while (h < A.length);
            return o;
        }
    },

    // md5 encode
    md5: function(A, B, C) {
        B = B || 8;
        C = C || 0;

        function safe_add(A, B) {
            var a, b;
            a = (A & 0xFFFF) + (B & 0xFFFF);
            b = (A >> 16) + (B >> 16) + (a >> 16);
            return (b << 16) | (a & 0xFFFF);
        }

        function bit_rol(A, B) {
            return (A << B) | (A >>> (32 - B));
        }

        function md5_cmn(q, a, b, x, s, t) {
            return safe_add(bit_rol(safe_add(safe_add(a, q), safe_add(x, t)), s), b);
        }

        function md5_ff(a, b, c, d, x, s, t) {
            return md5_cmn((b & c) | ((~b) & d), a, b, x, s, t);
        }

        function md5_gg(a, b, c, d, x, s, t) {
            return md5_cmn((b & d) | (c & (~d)), a, b, x, s, t);
        }

        function md5_hh(a, b, c, d, x, s, t) {
            return md5_cmn(b ^ c ^ d, a, b, x, s, t);
        }

        function md5_ii(a, b, c, d, x, s, t) {
            return md5_cmn(c ^ (b | (~d)), a, b, x, s, t);
        }

        function str2binl(A, B) {
            var a, b, z;
            B = B || 8;
            a = [];
            b = (1 << B) - 1;
            for (z = 0; z < A.length * B; z += B) a[z >> 5] |= (A.charCodeAt(z / B) & b) << (z % 32);
            return a;
        }

        function core_md5(A, B) {
            A[B >> 5] |= 0x80 << ((B) % 32);
            A[(((B + 64) >>> 9) << 4) + 14] = B;

            var a, b, c, d, a2, b2, c2, d2, z;
            a = 1732584193;
            b = -271733879;
            c = -1732584194;
            d = 271733878;

            for (z = 0; z < A.length; z += 16) {
                a2 = a;
                b2 = b;
                c2 = c;
                d2 = d;

                a = md5_ff(a, b, c, d, A[z + 0], 7, -680876936);
                d = md5_ff(d, a, b, c, A[z + 1], 12, -389564586);
                c = md5_ff(c, d, a, b, A[z + 2], 17, 606105819);
                b = md5_ff(b, c, d, a, A[z + 3], 22, -1044525330);
                a = md5_ff(a, b, c, d, A[z + 4], 7, -176418897);
                d = md5_ff(d, a, b, c, A[z + 5], 12, 1200080426);
                c = md5_ff(c, d, a, b, A[z + 6], 17, -1473231341);
                b = md5_ff(b, c, d, a, A[z + 7], 22, -45705983);
                a = md5_ff(a, b, c, d, A[z + 8], 7, 1770035416);
                d = md5_ff(d, a, b, c, A[z + 9], 12, -1958414417);
                c = md5_ff(c, d, a, b, A[z + 10], 17, -42063);
                b = md5_ff(b, c, d, a, A[z + 11], 22, -1990404162);
                a = md5_ff(a, b, c, d, A[z + 12], 7, 1804603682);
                d = md5_ff(d, a, b, c, A[z + 13], 12, -40341101);
                c = md5_ff(c, d, a, b, A[z + 14], 17, -1502002290);
                b = md5_ff(b, c, d, a, A[z + 15], 22, 1236535329);

                a = md5_gg(a, b, c, d, A[z + 1], 5, -165796510);
                d = md5_gg(d, a, b, c, A[z + 6], 9, -1069501632);
                c = md5_gg(c, d, a, b, A[z + 11], 14, 643717713);
                b = md5_gg(b, c, d, a, A[z + 0], 20, -373897302);
                a = md5_gg(a, b, c, d, A[z + 5], 5, -701558691);
                d = md5_gg(d, a, b, c, A[z + 10], 9, 38016083);
                c = md5_gg(c, d, a, b, A[z + 15], 14, -660478335);
                b = md5_gg(b, c, d, a, A[z + 4], 20, -405537848);
                a = md5_gg(a, b, c, d, A[z + 9], 5, 568446438);
                d = md5_gg(d, a, b, c, A[z + 14], 9, -1019803690);
                c = md5_gg(c, d, a, b, A[z + 3], 14, -187363961);
                b = md5_gg(b, c, d, a, A[z + 8], 20, 1163531501);
                a = md5_gg(a, b, c, d, A[z + 13], 5, -1444681467);
                d = md5_gg(d, a, b, c, A[z + 2], 9, -51403784);
                c = md5_gg(c, d, a, b, A[z + 7], 14, 1735328473);
                b = md5_gg(b, c, d, a, A[z + 12], 20, -1926607734);

                a = md5_hh(a, b, c, d, A[z + 5], 4, -378558);
                d = md5_hh(d, a, b, c, A[z + 8], 11, -2022574463);
                c = md5_hh(c, d, a, b, A[z + 11], 16, 1839030562);
                b = md5_hh(b, c, d, a, A[z + 14], 23, -35309556);
                a = md5_hh(a, b, c, d, A[z + 1], 4, -1530992060);
                d = md5_hh(d, a, b, c, A[z + 4], 11, 1272893353);
                c = md5_hh(c, d, a, b, A[z + 7], 16, -155497632);
                b = md5_hh(b, c, d, a, A[z + 10], 23, -1094730640);
                a = md5_hh(a, b, c, d, A[z + 13], 4, 681279174);
                d = md5_hh(d, a, b, c, A[z + 0], 11, -358537222);
                c = md5_hh(c, d, a, b, A[z + 3], 16, -722521979);
                b = md5_hh(b, c, d, a, A[z + 6], 23, 76029189);
                a = md5_hh(a, b, c, d, A[z + 9], 4, -640364487);
                d = md5_hh(d, a, b, c, A[z + 12], 11, -421815835);
                c = md5_hh(c, d, a, b, A[z + 15], 16, 530742520);
                b = md5_hh(b, c, d, a, A[z + 2], 23, -995338651);

                a = md5_ii(a, b, c, d, A[z + 0], 6, -198630844);
                d = md5_ii(d, a, b, c, A[z + 7], 10, 1126891415);
                c = md5_ii(c, d, a, b, A[z + 14], 15, -1416354905);
                b = md5_ii(b, c, d, a, A[z + 5], 21, -57434055);
                a = md5_ii(a, b, c, d, A[z + 12], 6, 1700485571);
                d = md5_ii(d, a, b, c, A[z + 3], 10, -1894986606);
                c = md5_ii(c, d, a, b, A[z + 10], 15, -1051523);
                b = md5_ii(b, c, d, a, A[z + 1], 21, -2054922799);
                a = md5_ii(a, b, c, d, A[z + 8], 6, 1873313359);
                d = md5_ii(d, a, b, c, A[z + 15], 10, -30611744);
                c = md5_ii(c, d, a, b, A[z + 6], 15, -1560198380);
                b = md5_ii(b, c, d, a, A[z + 13], 21, 1309151649);
                a = md5_ii(a, b, c, d, A[z + 4], 6, -145523070);
                d = md5_ii(d, a, b, c, A[z + 11], 10, -1120210379);
                c = md5_ii(c, d, a, b, A[z + 2], 15, 718787259);
                b = md5_ii(b, c, d, a, A[z + 9], 21, -343485551);

                a = safe_add(a, a2);
                b = safe_add(b, b2);
                c = safe_add(c, c2);
                d = safe_add(d, d2);
            }
            return Array(a, b, c, d);
        }

        function binl2hex(A, B) {
            var a, s, z;
            B = B || 0;
            a = B ? '0123456789ABCDEF' : '0123456789abcdef';
            s = '';
            for (z = 0; z < A.length * 4; z++) {
                s += a.charAt((A[z >> 2] >> ((z % 4) * 8 + 4)) & 0xF) + a.charAt((A[z >> 2] >> ((z % 4) * 8)) & 0xF);
            }
            return s;
        }

        return binl2hex(core_md5(str2binl(A), A.length * B), C);
    },

    padHex: function(hex, len) {
        while (hex.length < len) hex = "0" + hex;
        return hex;
    },

    utf8Encode: function(str) {
        var bytes = [];
        for (var i = 0; i < str.length; i++) {
            var code = str.charCodeAt(i);
            if (code < 0x80) {
            bytes.push(code);
            } else if (code < 0x800) {
            bytes.push(0xc0 | (code >> 6), 0x80 | (code & 0x3f));
            } else if (code < 0xd800 || code >= 0xe000) {
            bytes.push(0xe0 | (code >> 12), 0x80 | ((code >> 6) & 0x3f), 0x80 | (code & 0x3f));
            } else {
            i++;
            code = 0x10000 + (((code & 0x3ff) << 10) | (str.charCodeAt(i) & 0x3ff));
            bytes.push(
                0xf0 | (code >> 18),
                0x80 | ((code >> 12) & 0x3f),
                0x80 | ((code >> 6) & 0x3f),
                0x80 | (code & 0x3f)
            );
            }
        }
        return new Uint8Array(bytes);
    },

    // sha1 encode
    sha1: function(str) {
        // 辅助函数：32 位左旋
        function rotl(x, n) {
            return (x << n) | (x >>> (32 - n));
        }

        // 步骤 1: 文本转 UTF-8 字节数组
        var msgBuffer = this.utf8Encode(str);
        var msgArray = Array.from(msgBuffer);
        
        // 步骤 2: 预处理 - 填充
        var l = msgArray.length * 8;
        var padLength = (l % 512 <= 448 ? 448 : 960) - (l % 512);
        var bitsLeft = 512 - ((l + padLength + 64) % 512);
        
        // 添加 1 个 '1'，然后全是 '0'
        msgArray.push(0x80);
        for (var i = 0; i < Math.floor(padLength / 8) - 1; i++) {
            msgArray.push(0);
        }
        
        // 添加原始长度（bit 长度），大端序，64 位
        var highBits = Math.floor(l / 0x100000000);
        var lowBits = l & 0xFFFFFFFF;
        msgArray.push(...[
            (highBits >> 24) & 0xFF, (highBits >> 16) & 0xFF,
            (highBits >> 8) & 0xFF, highBits & 0xFF,
            (lowBits >> 24) & 0xFF, (lowBits >> 16) & 0xFF,
            (lowBits >> 8) & 0xFF, lowBits & 0xFF
        ]);

        // 步骤 3: 初始化哈希值（5 个 32 位常量）
        var h0 = 0x67452301;
        var h1 = 0xEFCDAB89;
        var h2 = 0x98BADCFE;
        var h3 = 0x10325476;
        var h4 = 0xC3D2E1F0;

        // 步骤 4: 处理每 512 位块
        for (var i = 0; i < msgArray.length; i += 64) {
            var chunk = msgArray.slice(i, i + 64);
            var w = new Array(80);

            // 将 512 位块拆分为 16 个 32 位字
            for (var j = 0; j < 16; j++) {
                w[j] = (
                    (chunk[j*4] << 24) |
                    (chunk[j*4+1] << 16) |
                    (chunk[j*4+2] << 8) |
                    (chunk[j*4+3])
                ) >>> 0;
            }

            // 扩展为 80 个字
            for (var j = 16; j < 80; j++) {
                w[j] = rotl(w[j-3] ^ w[j-8] ^ w[j-14] ^ w[j-16], 1);
            }

            // 主循环（80 轮）
            var a = h0, b = h1, c = h2, d = h3, e = h4;
            
            for (var j = 0; j < 80; j++) {
                var f, k;
                if (j < 20) {
                    f = (b & c) | (~b & d);
                    k = 0x5A827999;
                } else if (j < 40) {
                    f = b ^ c ^ d;
                    k = 0x6ED9EBA1;
                } else if (j < 60) {
                    f = (b & c) | (b & d) | (c & d);
                    k = 0x8F1BBCDC;
                } else {
                    f = b ^ c ^ d;
                    k = 0xCA62C1D6;
                }

                var temp = (rotl(a, 5) + f + e + k + w[j]) >>> 0;
                e = d;
                d = c;
                c = rotl(b, 30);
                b = a;
                a = temp;
            }

            // 更新哈希值
            h0 = (h0 + a) >>> 0;
            h1 = (h1 + b) >>> 0;
            h2 = (h2 + c) >>> 0;
            h3 = (h3 + d) >>> 0;
            h4 = (h4 + e) >>> 0;
        }

        // 步骤 5: 输出 160 位哈希（40 位 hex）
        return [
            this.padHex(h0.toString(16), 8),
            this.padHex(h1.toString(16), 8),
            this.padHex(h2.toString(16), 8),
            this.padHex(h3.toString(16), 8),
            this.padHex(h4.toString(16), 8),
        ].join('');
    },

    // SHA-256 轮函数使用的 64 个常量（来自立方根）
    k64: [
        0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
        0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
        0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
        0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
        0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
        0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
        0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
        0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2
    ],

    // sha256 encode
    sha256: function(str) {
        // 辅助函数
        function rotr(x, n) {
            return (x >>> n) | (x << (32 - n));
        }
        
        function ch(x, y, z) {
            return (x & y) ^ (~x & z);
        }
        
        function maj(x, y, z) {
            return (x & y) ^ (x & z) ^ (y & z);
        }
        
        function sigma0(x) {
            return rotr(x, 2) ^ rotr(x, 13) ^ rotr(x, 22);
        }
        
        function sigma1(x) {
            return rotr(x, 6) ^ rotr(x, 11) ^ rotr(x, 25);
        }
        
        function gamma0(x) {
            return rotr(x, 7) ^ rotr(x, 18) ^ (x >>> 3);
        }
        
        function gamma1(x) {
            return rotr(x, 17) ^ rotr(x, 19) ^ (x >>> 10);
        }

        // 1. UTF-8 编码
        var msg = this.utf8Encode(str);
        var msgArray = Array.from(msg);
        
        // 2. 预处理：填充消息
        var l = msgArray.length * 8;
        
        // 添加 1 位 (0x80)
        msgArray.push(0x80);
        
        // 添加 0 位直到长度 ≡ 448 (mod 512)
        while ((msgArray.length * 8) % 512 !== 448) {
            msgArray.push(0x00);
        }
        
        // 添加原始长度（64位，大端序）
        var lenHi = Math.floor(l / 0x100000000);
        var lenLo = l & 0xFFFFFFFF;
        
        msgArray.push((lenHi >>> 24) & 0xFF);
        msgArray.push((lenHi >>> 16) & 0xFF);
        msgArray.push((lenHi >>> 8) & 0xFF);
        msgArray.push(lenHi & 0xFF);
        msgArray.push((lenLo >>> 24) & 0xFF);
        msgArray.push((lenLo >>> 16) & 0xFF);
        msgArray.push((lenLo >>> 8) & 0xFF);
        msgArray.push(lenLo & 0xFF);

        // 3. 初始化哈希值
        var h = [
            0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a,
            0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19
        ];

        // 4. 处理每个 512 位块
        for (var i = 0; i < msgArray.length; i += 64) {
            // 准备消息调度数组 w[0..63]
            var w = new Array(64);
            
            // 将 512 位块转换为 16 个 32 位字
            for (var j = 0; j < 16; j++) {
                w[j] = (
                    (msgArray[i + j*4] << 24) |
                    (msgArray[i + j*4 + 1] << 16) |
                    (msgArray[i + j*4 + 2] << 8) |
                    (msgArray[i + j*4 + 3])
                ) >>> 0;
            }
            
            // 扩展 16 个字到 64 个字
            for (var j = 16; j < 64; j++) {
                w[j] = (gamma1(w[j-2]) + w[j-7] + gamma0(w[j-15]) + w[j-16]) >>> 0;
            }

            // 初始化工作变量
            var a = h[0], b = h[1], c = h[2], d = h[3];
            var e = h[4], f = h[5], g = h[6], h_val = h[7];

            // 主循环
            for (var j = 0; j < 64; j++) {
                var temp1 = (h_val + sigma1(e) + ch(e, f, g) + this.k64[j] + w[j]) >>> 0;
                var temp2 = (sigma0(a) + maj(a, b, c)) >>> 0;
                
                h_val = g;
                g = f;
                f = e;
                e = (d + temp1) >>> 0;
                d = c;
                c = b;
                b = a;
                a = (temp1 + temp2) >>> 0;
            }

            // 更新哈希值
            h[0] = (h[0] + a) >>> 0;
            h[1] = (h[1] + b) >>> 0;
            h[2] = (h[2] + c) >>> 0;
            h[3] = (h[3] + d) >>> 0;
            h[4] = (h[4] + e) >>> 0;
            h[5] = (h[5] + f) >>> 0;
            h[6] = (h[6] + g) >>> 0;
            h[7] = (h[7] + h_val) >>> 0;
        }

        // 5. 生成最终哈希值
        return h.map(function(val) {
            return this.padHex(val.toString(16), 8);
        }.bind(this)).join('');
    },

    // 80个64位常量 K (前80个素数的立方根小数部分)
    k80: [
        [0x428a2f98, 0xd728ae22], [0x71374491, 0x23ef65cd], [0xb5c0fbcf, 0xec4d3b2f], [0xe9b5dba5, 0x8189dbbc],
        [0x3956c25b, 0xf348b538], [0x59f111f1, 0xb605d019], [0x923f82a4, 0xaf194f9b], [0xab1c5ed5, 0xda6d8118],
        [0xd807aa98, 0xa3030242], [0x12835b01, 0x45706fbe], [0x243185be, 0x4ee4b28c], [0x550c7dc3, 0xd5ffb4e2],
        [0x72be5d74, 0xf27b896f], [0x80deb1fe, 0x3b1696b1], [0x9bdc06a7, 0x25c71235], [0xc19bf174, 0xcf692694],
        [0xe49b69c1, 0x9ef14ad2], [0xefbe4786, 0x384f25e3], [0x0fc19dc6, 0x8b8cd5b5], [0x240ca1cc, 0x77ac9c65],
        [0x2de92c6f, 0x592b0275], [0x4a7484aa, 0x6ea6e483], [0x5cb0a9dc, 0xbd41fbd4], [0x76f988da, 0x831153b5],
        [0x983e5152, 0xee66dfab], [0xa831c66d, 0x2db43210], [0xb00327c8, 0x98fb213f], [0xbf597fc7, 0xbeef0ee4],
        [0xc6e00bf3, 0x3da88fc2], [0xd5a79147, 0x930aa725], [0x06ca6351, 0xe003826f], [0x14292967, 0x0a0e6e70],
        [0x27b70a85, 0x46d22ffc], [0x2e1b2138, 0x5c26c926], [0x4d2c6dfc, 0x5ac42aed], [0x53380d13, 0x9d95b3df],
        [0x650a7354, 0x8baf63de], [0x766a0abb, 0x3c77b2a8], [0x81c2c92e, 0x47edaee6], [0x92722c85, 0x1482353b],
        [0xa2bfe8a1, 0x4cf10364], [0xa81a664b, 0xbc423001], [0xc24b8b70, 0xd0f89791], [0xc76c51a3, 0x0654be30],
        [0xd192e819, 0xd6ef5218], [0xd6990624, 0x5565a910], [0xf40e3585, 0x5771202a], [0x106aa070, 0x32bbd1b8],
        [0x19a4c116, 0xb8d2d0c8], [0x1e376c08, 0x5141ab53], [0x2748774c, 0xdf8eeb99], [0x34b0bcb5, 0xe19b48a8],
        [0x391c0cb3, 0xc5c95a63], [0x4ed8aa4a, 0xe3418acb], [0x5b9cca4f, 0x7763e373], [0x682e6ff3, 0xd6b2b8a3],
        [0x748f82ee, 0x5defb2fc], [0x78a5636f, 0x43172f60], [0x84c87814, 0xa1f0ab72], [0x8cc70208, 0x1a6439ec],
        [0x90befffa, 0x23631e28], [0xa4506ceb, 0xde82bde9], [0xbef9a3f7, 0xb2c67915], [0xc67178f2, 0xe372532b],
        [0xca273ece, 0xea26619c], [0xd186b8c7, 0x21c0c207], [0xeada7dd6, 0xcde0eb1e], [0xf57d4f7f, 0xee6ed178],
        [0x06f067aa, 0x72176fba], [0x0a637dc5, 0xa2c898a6], [0x113f9804, 0xbef90dae], [0x1b710b35, 0x131c471b],
        [0x28db77f5, 0x23047d84], [0x32caab7b, 0x40c72493], [0x3c9ebe0a, 0x15c9bebc], [0x431d67c4, 0x9c100d4c],
        [0x4cc5d4be, 0xcb3e42b6], [0x597f299c, 0xfc657e2a], [0x5fcb6fab, 0x3ad6faec], [0x6c44198c, 0x4a475817]
    ],

    // sha512 encode
    sha512: function(str) {
        // 初始化状态
        var h0 = [0x6a09e667, 0xf3bcc908];
        var h1 = [0xbb67ae85, 0x84caa73b];
        var h2 = [0x3c6ef372, 0xfe94f82b];
        var h3 = [0xa54ff53a, 0x5f1d36f1];
        var h4 = [0x510e527f, 0xade682d1];
        var h5 = [0x9b05688c, 0x2b3e6c1f];
        var h6 = [0x1f83d9ab, 0xfb41bd6b];
        var h7 = [0x5be0cd19, 0x137e2179];

        var that = this;
        var buffer = new Uint8Array(128); // 1024位缓冲区
        var bufferLen = 0;
        var bytesLow = 0;
        var bytesHigh = 0;
        var finalized = false;

        // 64位加法
        function add64(a, b) {
            var low = (a[1] + b[1]) | 0;
            var high = (a[0] + b[0] + ((low >>> 0) < (a[1] >>> 0) ? 1 : 0)) | 0;
            return [high, low];
        }

        // 64位右旋转
        function rotr64(x, n) {
            var h = x[0], l = x[1];
            if (n < 32) {
                return [
                    ((h >>> n) | (l << (32 - n))) | 0,
                    ((l >>> n) | (h << (32 - n))) | 0
                ];
            } else {
                return [
                    ((l >>> (n - 32)) | (h << (64 - n))) | 0,
                    ((h >>> (n - 32)) | (l << (64 - n))) | 0
                ];
            }
        }

        // 64位逻辑右移
        function shr64(x, n) {
            var h = x[0], l = x[1];
            if (n >= 64) return [0, 0];
            if (n >= 32) return [0, (h >>> (n - 32)) | 0];
            return [
                (h >>> n) | 0,
                ((l >>> n) | (h << (32 - n))) | 0
            ];
        }

        // sigma0
        function sigma0(x) {
            var r1 = rotr64(x, 1);
            var r2 = rotr64(x, 8);
            var s = shr64(x, 7);
            return [r1[0] ^ r2[0] ^ s[0], r1[1] ^ r2[1] ^ s[1]];
        }

        // sigma1
        function sigma1(x) {
            var r1 = rotr64(x, 19);
            var r2 = rotr64(x, 61);
            var s = shr64(x, 6);
            return [r1[0] ^ r2[0] ^ s[0], r1[1] ^ r2[1] ^ s[1]];
        }

        // Sigma0
        function Sigma0(x) {
            var r1 = rotr64(x, 28);
            var r2 = rotr64(x, 34);
            var r3 = rotr64(x, 39);
            return [r1[0] ^ r2[0] ^ r3[0], r1[1] ^ r2[1] ^ r3[1]];
        }

        // Sigma1
        function Sigma1(x) {
            var r1 = rotr64(x, 14);
            var r2 = rotr64(x, 18);
            var r3 = rotr64(x, 41);
            return [r1[0] ^ r2[0] ^ r3[0], r1[1] ^ r2[1] ^ r3[1]];
        }

        // Ch
        function Ch(x, y, z) {
            return [
                (x[0] & y[0]) ^ (~x[0] & z[0]),
                (x[1] & y[1]) ^ (~x[1] & z[1])
            ];
        }

        // Maj
        function Maj(x, y, z) {
            return [
                (x[0] & y[0]) ^ (x[0] & z[0]) ^ (y[0] & z[0]),
                (x[1] & y[1]) ^ (x[1] & z[1]) ^ (y[1] & z[1])
            ];
        }

        // 更新输入
        function update(data) {
            if (finalized) return;

            var bytes;
            if (typeof data === "string") {
                bytes = that.utf8Encode(data);
            } else if (data instanceof Uint8Array) {
                bytes = data;
            } else {
                bytes = new Uint8Array(data);
            }

            var pos = 0;
            while (pos < bytes.length) {
                if (bufferLen === 128) {
                    processBlock();
                }
                buffer[bufferLen++] = bytes[pos++];
            }

            var oldBytesLow = bytesLow;
            bytesLow += bytes.length;
            if (bytesLow < oldBytesLow) bytesHigh++;
            bytesHigh += Math.floor(bytes.length / 0x100000000);
        }

        // 处理一个块
        function processBlock() {
            var w = new Array(80);
            for (var i = 0; i < 80; i++) w[i] = [0, 0];

            // 解析前16个64位字
            for (var i = 0; i < 16; i++) {
                var off = i * 8;
                w[i][0] = (
                    (buffer[off    ] << 24) |
                    (buffer[off + 1] << 16) |
                    (buffer[off + 2] <<  8) |
                    (buffer[off + 3])
                ) | 0;
                w[i][1] = (
                    (buffer[off + 4] << 24) |
                    (buffer[off + 5] << 16) |
                    (buffer[off + 6] <<  8) |
                    (buffer[off + 7])
                ) | 0;
            }

            // 扩展消息调度
            for (var i = 16; i < 80; i++) {
                var s0 = sigma0(w[i-15]);
                var s1 = sigma1(w[i-2]);
                var t1 = add64(add64(add64(w[i-16], s0), w[i-7]), s1);
                w[i] = t1;
            }

            var a = [h0[0], h0[1]], b = [h1[0], h1[1]], c = [h2[0], h2[1]], d = [h3[0], h3[1]];
            var e = [h4[0], h4[1]], f = [h5[0], h5[1]], g = [h6[0], h6[1]], h = [h7[0], h7[1]];

            for (var i = 0; i < 80; i++) {
                var S1 = Sigma1(e);
                var ch = Ch(e, f, g);
                var temp1 = add64(add64(add64(add64(h, S1), ch), that.k80[i]), w[i]);
                var S0 = Sigma0(a);
                var maj = Maj(a, b, c);
                var temp2 = add64(S0, maj);

                h = g; g = f; f = e; e = add64(d, temp1);
                d = c; c = b; b = a; a = add64(temp1, temp2);
            }

            h0 = add64(h0, a);
            h1 = add64(h1, b);
            h2 = add64(h2, c);
            h3 = add64(h3, d);
            h4 = add64(h4, e);
            h5 = add64(h5, f);
            h6 = add64(h6, g);
            h7 = add64(h7, h);

            bufferLen = 0;
        }

        // 完成并输出
        function finalize() {
            if (finalized) return;
            finalized = true;

            buffer[bufferLen++] = 0x80;

            while (bufferLen % 128 !== 112) {
                if (bufferLen === 128) processBlock();
                buffer[bufferLen++] = 0;
            }

            var bitLenLow = bytesLow * 8;
            var bitLenHigh = (bytesHigh * 8) + (bytesLow >>> 29);

            buffer[120] = (bitLenHigh >>> 24) & 0xff;
            buffer[121] = (bitLenHigh >>> 16) & 0xff;
            buffer[122] = (bitLenHigh >>>  8) & 0xff;
            buffer[123] = (bitLenHigh      ) & 0xff;
            buffer[124] = (bitLenLow  >>> 24) & 0xff;
            buffer[125] = (bitLenLow  >>> 16) & 0xff;
            buffer[126] = (bitLenLow  >>>  8) & 0xff;
            buffer[127] = (bitLenLow       ) & 0xff;

            processBlock();
        }

        // 执行
        update(str);
        finalize();

        // 生成十六进制输出
        var h = [h0, h1, h2, h3, h4, h5, h6, h7];
        var hex = '';
        for (var i = 0; i < 8; i++) {
            hex += that.padHex((h[i][0] >>> 0).toString(16), 8);
            hex += that.padHex((h[i][1] >>> 0).toString(16), 8);
        }
        return hex.toLowerCase();
    },

    // sha encode
    sha: function(str, type=2) {
        if(type == 1) return this.sha1(str);
        else if(type == 2) return this.sha256(str);
        else return this.sha512(str);
    },

    // get node, 获取节点
    gn: function(A) {
        var a, b, c, d, e, f, g, l, o, s, Z;
        o = A;
        if (typeof A == 'string') {
            a = A.substr(0, 1);
            if (a == '#') {
                a = A.substr(1);
                o = document.getElementById(a);
            } else if (a == '.') {
                a = A.substr(1);
                o = document.getElementsByClassName(a)[0];
            } else {
                o = document.getElementById(A);
            }
        }

        if (!o) return null;
        else if (o == window) return o;
        try {
            f = o.nodeType;
            g = o.getAttribute;
            s = o.style;
            t = o.tagName;
        } catch (e) {
            f = 0;
            g = 0;
            s = 0;
            t = 0;
        }
        if (!f || !g || !s || !t) return null;

        o.c = o.getAttribute('style');
        o.p = o.parentNode;
        if (o.p && o.p.parentNode) o.pp = o.p.parentNode;
        if (o.pp && o.pp.parentNode) o.ppp = o.pp.parentNode;
        o.h = o.innerHTML;
        o.o = o.outerHTML;
        o.t = o.textContent || o.innerText;
        o.cn = o.className;
        o.tn = o.tagName;
        o.nt = o.nodeType;
        o.nv = o.nodeValue;
        o.fc = o.firstChild;
        if (o.fc && o.fc.nextSibling) o.f1 = o.fc.nextSibling;
        if (o.f1 && o.f1.nextSibling) o.f2 = o.f1.nextSibling;
        if (o.f2 && o.f2.nextSibling) o.f3 = o.f2.nextSibling;
        o.lc = o.lastChild;
        if (o.lc && o.lc.previousSibling) o.l1 = o.lc.previousSibling;
        if (o.l1 && o.l1.previousSibling) o.l2 = o.l1.previousSibling;
        if (o.l2 && o.l2.previousSibling) o.l3 = o.l2.previousSibling;
        o.pn = o.previousSibling;
        if (o.pn && o.pn.previousSibling) o.p1 = o.pn.previousSibling;
        if (o.p1 && o.p1.previousSibling) o.p2 = o.p1.previousSibling;
        if (o.p2 && o.p2.previousSibling) o.p3 = o.p2.previousSibling;
        o.nn = o.nextSibling;
        if (o.nn && o.nn.nextSibling) o.n1 = o.nn.nextSibling;
        if (o.n1 && o.n1.nextSibling) o.n2 = o.n1.nextSibling;
        if (o.n2 && o.n2.nextSibling) o.n3 = o.n2.nextSibling;
        o.cd = o.childNodes;
        o.cdl = o.childNodes.length;
        o.ow = o.offsetWidth;
        o.oh = o.offsetHeight;
        o.lw = o.scrollWidth;
        o.lh = o.scrollHeight;
        o.ol = o.offsetLeft;
        o.ot = o.offsetTop;
        o.ml = parseInt(o.style.marginLeft) || 0;
        o.mt = parseInt(o.style.marginTop) || 0;
        o.st = o.scrollTop;
        if (o.tn == 'INPUT' || o.tn == 'TEXTAREA') o.v = o.value || '';
        else o.v = '';
        return o;
    },

    // node css
    css: function(A, B, C) {
        var a, b, c, d
        A = this.gn(A);
        if (!A) return;
        a = {
            bd: 'border',
            bdt: 'borderTop',
            bdb: 'borderBottom',
            bdl: 'borderLeft',
            bdr: 'borderRight',
            bdm: 'borderMode',
            bdw: 'borderWidth',
            bdc: 'borderColor',
            bds: 'borderStyle',
            bdi: 'borderImage',
            bdtw: 'borderTopWidth',
            bdtc: 'borderTopColor',
            bdts: 'borderTopStyle',
            bdti: 'borderTopImage',
            bdbw: 'borderBottomWidth',
            bdbc: 'borderBottomColor',
            bdbs: 'borderBottomStyle',
            bdbi: 'borderBottomImage',
            bdlw: 'borderLeftWidth',
            bdlc: 'borderLeftColor',
            bdls: 'borderLeftStyle',
            bdli: 'borderLeftImage',
            bdrw: 'borderRightWidth',
            bdrc: 'borderRightColor',
            bdrs: 'borderRightStyle',
            bdri: 'borderRightImage',
            oc: 'outlineColor',
            os: 'outlineStyle',
            ow: 'outlineWidth',
            pd: 'padding',
            pdt: 'paddingTop',
            pdr: 'paddingRight',
            pdb: 'paddingBottom',
            pdl: 'paddingLeft',
            mg: 'margin',
            mgt: 'marginTop',
            mgr: 'marginRight',
            mgb: 'marginBottom',
            mgl: 'marginLeft',
            ff: 'fontFamily',
            fs: 'fontSize',
            fe: 'fontStyle',
            fc: 'color',
            fw: 'fontWeight',
            ta: 'textAlign',
            va: 'verticalAlign',
            lh: 'lineHeight',
            ls: 'letterSpacing',
            ws: 'whiteSpace',
            td: 'textDecoration',
            ti: 'textIndent',
            p: 'position',
            o: 'opacity',
            z: 'zIndex',
            sf: 'styleFloat',
            cl: 'clear',
            ox: 'overflowX',
            oy: 'overflowY',
            cs: 'cursor',
            d: 'display',
            v: 'visibility',
            w: 'width',
            nw: 'minWidth',
            xw: 'maxWidth',
            mw: 'normalWidth',
            h: 'height',
            nh: 'minHeight',
            xh: 'maxHeight',
            mh: 'normalHeight',
            l: 'left',
            r: 'right',
            t: 'top',
            b: 'bottom',
            br: 'borderRadius',
            bg: 'background',
            bgc: 'backgroundColor',
            bgi: 'backgroundImage',
            bgr: 'backgroundRepeat',
            bgx: 'backgroundPositionX',
            bgy: 'backgroundPositionY'
        };
        if (this.ud.ie) a.sf = 'cssFloat';
        B = a[B] || B;
        if (!C && C !== 0) return A.style[B] || '';
        else A.style[B] = C;
    },

    // add css
    ac: function(A, B, C) {
        var a, b, c, d;
        A = 'CSS_' + A;
        a = this.gn(A);
        d = 'style';
        if (C == 2) d = 'link';
        if (!a) {
            a = document.head.appendChild(document.createElement('style'));
            a.id = A;
            this.na(a, 'type', 'text/css');
        }
        if (C == 2) {
            this.na(a, 'rel', 'stylesheet');
            this.na(a, 'href', B);
        } else {
            if (this.ud.ie) a.styleSheet.cssText = B;
            else a.innerHTML = B;
        }
        return a;
    },

    // add js
    aj: function(A, B, C, D) {
        var a, b, c, d, Z;
        A = 'JS_' + A;
        C = C || 1;
        a = this.gn(A);
        if (!a) {
            a = document.head.appendChild(document.createElement('script'));
            a.id = A;
            this.na(a, 'type', 'text/javascript');
        }
        if (C == 1) a.text = B;
        else this.na(a, 'src', B);
        if (!D) return a;
        a.onload = D;
    },

    // add node
    an: function(A, B, C, D) {
        var a, b, c, d;
        A = this.gn(A);
        C = C || 1;
        D = D || 'i';
        if (!A) return;
        a = this.gn(B);
        if (!a) {
            a = document.createElement(D);
            a.id = B;
        }
        if (C == 1) A.appendChild(a);
        else if (C == 2 && A.fc) A.insertBefore(a, A.fc);
        else A.appendChild(a);
        a = this.gn(B);
        return a;
    },

    // delete node
    dn: function(A) {
        var a, b, c, d;
        A = this.gn(A);
        if (!A) return;
        return A.p.removeChild(A);
    },

    // delete node list
    dnl: function(A, B) {
        var a, b, c, d, z;
        A = A || '';
        B = B || '';
        if (!A) return;
        if (B) B = B + '_';
        a = A.split(',');
        b = a.length;
        for (z = 0; z < b; z++) {
            c = B + (a[z] || '').trim();
            d = this.gn(c);
            if (d) d.parentNode.removeChild(d);
        }
    },

    // copy node
    cn: function(A, B) {
        var a, b, c, d;
        A = this.gn(A);
        if (!A) return;
        B = B || 1;
        if (B) return A.coloneNode(true);
        else return A.coloneNode(false);
    },

    // copy node text
    cp: function(A) {
        var a, b;
        A = this.gn(A);
        if (!A) return;
        a = A.t || A.v;
        if (a) {
            if (!this.ud.copy) this.ud.copy = [a];
            else this.ud.copy.unshift(a);
            this.msg('成功复制: ' + a.substr(0, 15) + '...');
            b = this.ud.copy.length;
            if (b > 20) this.ud.copy.splice(b - 1, 1);
        }
    },

    // copy text
    ct: function(A) {
        var a, b, c, d, that;
        that = this;
        a = this.gn(A);
        if (!a) return;
        b = this.nv(a) || '';
        if (!b) return this.msg('无效内容');
        c = navigator.clipboard;
        if (!c) return this.msg('操作不支持，请选择文本后手动复制');
        c.writeText(b).then(function() {
            that.msg('成功复制文本到剪贴板');
        }).catch (function() {
            that.msg('操作不支持，请选择文本后手动复制');
        });
    },

    // move node
    mn: function(A, B, C) {
        var a, b, c, d;
        A = this.gn(A);
        B = this.gn(B);
        C = C || 1;
        if (!A || !B) return;
        a = A.coloneNode(true);
        if (C == 1) B.p.insertBefore(a, B);
        else if (B.nn) B.p.insertBefore(a, B.nn);
        else B.p.appendChild(a);
        A.p.removeChild(A);
        return a;
    },

    // replace node
    rn: function(A, B) {
        var a, b, c, d;
        A = this.gn(A);
        B = this.gn(B);
        if (!A || !B) return;
        return B.p.replaceChild(A, B);
    },

    // node attribute
    na: function(A, B, C) {
        var a, b, c, d;
        A = this.gn(A);
        if (!A) return;
        a = C || '';
        if (C === undefined) return A.getAttribute(B) || '';
        else if (B) A.setAttribute(B, a);
    },

    // node text
    nt: function(A, B) {
        var a, b, c, d;
        A = this.gn(A);
        if (!A) return;
        if (B === undefined) {
            return A.t;
        } else {
            if (this.ud.ie) A.innerText = B;
            else A.textContent = B;
        }
    },

    // node value
    nv: function(A, B) {
        var a, b, c, d;
        A = this.gn(A);
        if (!A) return;
        a = A.tn;
        if (B === undefined) {
            return A.v;
        } else {
            if (a == 'INPUT' || a == 'TEXTAREA') A.value = B;
        }
    },

    // show node, 显示节点
    sn: function(A, B, C, D) {
        var a, b, c, d, e, f, t, z;
        A = this.gn(A);
        if (!A) return;
        B = B || ''; // a(max), i(min), n(nor), f(focus)
        C = C || 0; // time(m), auto hide time
        D = D || ''; // a(max), i(min), n(nor), f(focus)
        clearTimeout(A.getAttribute('tid'));
        a = A.className;
        a = a.replace(/ *h_/g, '');
        A.className = a;
        if (B) this.ws(A, B);

        if (C > 0) {
            t = setTimeout(function() {
                ryo.hn(A, D);
            }, C * 1000);
            A.setAttribute('tid', t);
        }
    },

    // hide node, 隐藏节点
    hn: function(A, B) {
        var a, b, c, d;
        A = this.gn(A);
        B = B || ''; // a(max), i(min), n(nor), f(focus)
        if (!A) return;
        a = A.className;
        a = a.replace(/ *h_/g, '');

        if (B) this.ws(A, B);
        else A.className = a + ' h_';
    },

    // show or hide, 显示或隐藏节点
    sh: function(A, B, C) {
        var a, b, c, d;
        A = this.gn(A);
        B = B || ''; // a(max), i(min), n(nor), f(focus)
        C = C || ''; // a(max), i(min), n(nor), f(focus)
        if (!A) return;
        a = A.className;
        if (B && C) {
            if (A.indexOf(B) > -1) this.ws(A, C);
            else this.ws(A, B);
        } else {
            if (a.indexOf('h_') > -1) this.sn(A, B);
            else this.hn(A, C);
        }
    },

    // select node, 选中节点
    sel: function(A) {
        var a, b, c, d, l, z;
        A = this.gn(A);
        if (!A) return '';
        a = A.getAttribute('ss'); // select state
        b = A.className;
        if (a == 1) return null;
        l = A.parentNode.childNodes;
        for (z = 0; z < l.length; z++) {
            if (l[z].nodeType != 1) continue;
            c = l[z].className;
            l[z].className = c.replace(/ *s_/g, '');
            l[z].setAttribute('ss', '0');
        }
        A.className = b + ' s_';
        A.setAttribute('ss', '1');
    },

    // select node's all childNodes
    selAll: function(A, B) {
        var a, b, c, d, e, f, l, s, z;
        A = this.gn(A);
        B = B || 0;
        s = [];
        a = A.cd;
        l = A.cdl;
        for (z = 0; z < l; z++) {
            if (a[z].nodeType != 1) continue;
            b = a[z].getAttribute('ss');
            if (B > 0) {
                e = parseInt(a[z].id);
                if (b == 1 && e) s.push(e);
                continue;
            }
            if (b > 1) continue;
            c = a[z].className;
            c = c.replace(/ *s_/g, '');
            a[z].className = c + ' s_';
            a[z].setAttribute('ss', '1');
        }
        if (B > 0) return s;
        else return [];
    },

    // select invert
    selNo: function(A) {
        var a, b, c, d, l, z;
        A = this.gn(A);
        a = A.cd;
        l = A.cdl;
        for (z = 0; z < l; z++) {
            if (a[z].nodeType != 1) continue;
            b = a[z].getAttribute('ss');
            if (b > 1) continue;
            if (b == 1) {
                c = a[z].className;
                c = c.replace(/ *s_/g, '');
                a[z].className = c;
                a[z].setAttribute('ss', '0');
            } else {
                c = a[z].className;
                c = c.replace(/ *s_/g, '');
                a[z].className = c + ' s_';
                a[z].setAttribute('ss', '1');
            }
        }
    },

    // select state
    ss: function(A) {
        var a, b, c, d, n, o;
        o = this.obj(A);
        a = this.gn(o.nid);
        b = a.className || '';
        b = b.replace(/ *s4_/g, '');
        if (o.sel == 1) {
            a.className = b + ' s4_';
        } else {
            a.className = b;
        }
        c = typeof o.txt;
        if (c == 'number' || (c == 'string' && o.txt)) {
            if (a.firstChild.nextSibling.nodeType === Node.TEXT_NODE) a.firstChild.nextSibling.nodeValue = this.nfmt(o.txt);
            d = this.na(a, 'msg') || '';
            if (d) this.na(a, 'title', d + o.txt);
        }
        c = typeof o.fans;
        if (c == 'number' || (c == 'string' && o.fans)) {
            n = this.gn('fans_' + o.nid);
            if (n.firstChild.nextSibling.nodeType === Node.TEXT_NODE) n.firstChild.nextSibling.nodeValue = this.nfmt(o.fans);
            d = this.na(n, 'msg') || '';
            if (d) this.na(n, 'title', d + o.fans);
        }
    },

    // window size, 重设窗口大小
    ws: function(A, B) {
        var a, b, c, d;
        A = this.gn(A);
        if (!A || !B) return;
        a = b = A.className; // max, min, nor, focus
        a = a.replace(/ *[ainf]_/g, '');
        if (B == 1) {
            if (b.indexOf('n_') > -1) A.className = a + ' i_';
            else A.className = a + ' n_';
        } else if (B == 2) {
            if (b.indexOf('i_') > -1) A.className = a + ' a_';
            else A.className = a + ' i_';
        } else if (B == 3) {
            if (b.indexOf('n_') > -1) A.className = a + ' a_';
            else if (b.indexOf('a_') > -1) A.className = a + ' i_';
            else A.className = a + ' n_';
        } else if (B == 4) {
            if (b.indexOf('n_') > -1) A.className = a + ' a_';
            else if (b.indexOf('a_') > -1) A.className = a + ' f_';
            else A.className = a + ' n_';
        } else {
            A.className = a + ' ' + B;
        }
    },

    // modify user info
    mui: function(A, B) {
        var a, b, c, d, m, n, p, s, t, v;
        n = this.gn(A).previousSibling;
        p = n.parentNode;
        a = p.className;
        b = a.replace(/ *e_/g, '');
        c = this.na(n, 'is');
        d = this.na(n, 'kn');

        if (d == 'user_il') {
            n.select();
            this.ct(n);
            return;
        }

        if (c == 'cg') {
            this.na(n, 'readonly', 'true');
            n.blur();
            this.na(n, 'is', 'ed');
            p.className = b;
        } else {
            n.removeAttribute('readonly');
            n.focus();
            this.na(n, 'is', 'ed');
            p.className = b + ' e_';
            return;
        }

        v = n.value || '';
        if (!v && v != 0) return this.msg('无效值');
        v = this.e36(v);
        m = ',user_wec,user_ali,user_pp,user_bc,';
        s = ',user_sc,user_up,user_tp,user_mob,user_mail,';
        t = (d || '').substr(5, 1);
        if (d == 'user_mail') t = 'e';

        if (d == 'user_ava') {
            b = confirm('每周只能修改一次用户头像，是否继续？');
            if (!b) return this.msg('终止操作');
            c = 'f`ma`url`' + v;
        } else if (d == 'user_nn') {
            b = confirm('每周只能修改一次用户昵称，是否继续？');
            if (!b) return this.msg('终止操作');
            c = 'f`mn`tp`1`new`' + v;
        } else if (d == 'user_un') {
            b = confirm('每月只能修改一次用户名，是否继续？');
            if (!b) return this.msg('终止操作');
            c = 'f`mn`tp`2`new`' + v;
        } else if (d == 'user_sn') {
            b = confirm('每月只能修改一次门派名称，是否继续？');
            if (!b) return this.msg('终止操作');
            c = 'f`mn`tp`3`new`' + v;
        } else if (s.indexOf(',' + d + ',') != -1) {
            b = prompt('请输入安全码进行验证');
            if (!b) return this.msg('终止操作');
            c = 'f`ms`mt`' + t + '`vt`s`vc`' + b + '`new`' + v;
        } else if (m.indexOf(',' + d + ',') != -1) {
            b = prompt('请输入交易密码进行验证');
            if (!b) return this.msg('终止操作');
            c = 'f`ms`mt`' + t + '`vt`t`vc`' + b + '`new`' + v;
        } else {
            return this.msg('未知修改类型');
        }
        this.req(c);
    },

    // modify user info help
    muih: function(A) {
        var a, b, c, d, n, p;
        n = this.gn(A);
        a = this.na(n, 'kn');
        if (a == 'user_amn') b = '活动资金/余额/可用余额';
        else if (a == 'user_fmn') b = '冻结资金/不可用余额';
        else if (a == 'user_imn') b = '收入资金/奖励资金/佣金提成/奖励提成';
        else if (a == 'user_il') {
            this.gd('f`vd`tb`user`kw`tag.qrlink`ctn`qrlinkCtn`tpl`qrlink');
            return;
        }
        this.gd('f`ld`tb`dyna`kw`ctp.1,ip.0,tag.' + b);
    },

    // user agent
    ua: function() {
        var a, s, u;
        u = window.navigator.userAgent.toLowerCase();
        a = [];
        s = '';
        (s = u.match(/trident\/7([\d.]+)/)) ? a.push('IE', '11'): (s = u.match(/msie ([\d.]+)/)) ? a.push('IE', s[1]) : (s = u.match(/firefox\/([\d.]+)/)) ? a.push('Firefox', s[1]) : (s = u.match(/bidubrowser\/([\d.]+)/)) ? a.push('Baidu', s[1]) : (s = u.match(/taobrowser\/([\d.]+)/)) ? a.push('Taobao', s[1]) : (s = u.match(/se ([\d.]+)/)) ? a.push('Sogou', s[1]) : (s = u.match(/opr\/([\d.]+)/)) ? a.push('Opera', s[1]) : (s = u.match(/chrome\/([\d.]+)/)) ? a.push('Chrome', s[1]) : (s = u.match(/version\/([\d.]+).*safari/)) ? a.push('Safari', s[1]) : a.push('null', '0');

        (s = u.match(/windows nt ([\d.]+)/)) ? a.push('Windows', s[1] > '6.1' ? '8' : s[1] == '6.1' ? '7' : s[1] == '6.0' ? 'Vista' : s[1] == '5.2' ? '2003' : s[1] == '5.1' ? 'XP' : '2000'): (s = u.match(/linux((os\/)|( x))([\d.*_*\d]+)/)) ? a.push('Linux', s[1] == ' x' ? 'x' + s[4] : s[4]) : (s = u.match(/mac os x ([\d.*_*\d_*\d]+)/)) ? a.push('Mac', s[1]) : (s = u.match(/iphone os ([\d.]+)/)) ? a.push('iPhone', s[1]) : (s = u.match(/ipad; cpu os ([\d.*_*\d_*\d]+)/)) ? a.push('ipad', s[1]) : (s = u.match(/android ([\d.]+)/)) ? a.push('Android', s[1]) : (s = u.match(/symbianos\/([\d.]+)/)) ? a.push('Symbian', s[1]) : a.push('null', '0');

        a.push(screen.width, screen.height);

        (s = u.match(/baidu.com/)) ? a.push('Baidu'): (s = u.match(/(google.com)|(googlebot.com)/)) ? a.push('Google') : (s = u.match(/sogou.com/)) ? a.push('Sogou') : (s = u.match(/soso.com/)) ? a.push('Soso') : (s = u.match(/yahoo.com/)) ? a.push('Yahoo') : (s = u.match(/youdao.com/)) ? a.push('Youdao') : (s = u.match(/msn.com/)) ? a.push('MSN') : (s = u.match(/bing.com/)) ? a.push('Bing') : (s = u.match(/iask.com/)) ? a.push('Iask') : (s = u.match(/jike.com/)) ? a.push('Jike') : a.push('null');

        return a;
    },

    // get event obj
    ge: function() {
        var a, b;
        b = window.event;
        if (b) return b;
        a = ryo.ge.caller;
        while (a != null) {
            b = a.arguments[0];
            if (b) {
                if ((b.constructor == Event || b.constructor == MouseEvent) || (typeof b == 'object' && b.preventDefault && b.stopPropagation)) return b;
            }
            a = a.caller;
        }
        return null;
    },

    // add event obj
    ae: function(A, B, C, D) { // add event obj
        A = ryo.gn(A);
        if (!A) return;
        D = D || true;
        if(A.addEventListener) A.addEventListener(B, C, D);
        else if (A.attachEvent) A.attachEvent('on' + B, C);
    },

    // stop event
    se: function() {
        var e = ryo.ge();
        if (e.cancelBubble) e.cancelBubble = true;
        else e.stopPropagation();
    },

    // mouse over(in)
    mi: function(A) {
        var a, b, c, d, o, t;
        A = A || window.event;
        o = A.srcElement || A.target;
    },

    // mouse down
    md: function(A) {
        var a, b, c, d, o, t, z;
        A = A || window.event;
        o = A.srcElement || A.target;
        ryo.gv.gst = new Date().getTime(); // gesture start
        ryo.gv.ges = '';
        ryo.gv.mn = null; // move node
        if (A.pageX || A.pageY) {
            ryo.gv.x1 = A.pageX;
            ryo.gv.y1 = A.pageY;
        } else {
            ryo.gv.x1 = A.clientX;
            ryo.gv.y1 = A.clientY;
        }

        a = o;
        z = 0;
        while (z++ < 5) {
            if (!a || a.tagName == 'BODY') break;
            b = ryo.na(a, 'mn');
            if (b == 1) {
                ryo.gv.mn = a;
                break;
            } else if (b == '0') break;
            a = a.parentNode;
        }

        if (ryo.gv.mn) {
            ryo.gv.l1 = a.offsetLeft || 0;
            ryo.gv.t1 = a.offsetTop || 0;
            if (a.style) {
                ryo.gv.ml = a.style.marginLeft || 0;
                ryo.gv.mt = a.style.marginTop || 0;
            } else {
                ryo.gv.ml = 0;
                ryo.gv.mt = 0;
            }
        }
    },

    // mouse move
    mm: function(A) {
        var a, b, c, d, m, w, h, o, s, x, y, l2, t2, ml, mt;
        A = A || window.event;
        o = A.srcElement || A.target;
        if (A.pageX || A.pageY) {
            ryo.gv.x = x = A.pageX;
            ryo.gv.y = y = A.pageY;
        } else {
            ryo.gv.x = x = A.clientX;
            ryo.gv.y = y = A.clientY;
        }
        //ryo.msg(x + ' ' + y);

        if (ryo.gv.mn) {
            m = ryo.na(ryo.gv.mn, 'mm') || 0; // move mode
            x = ryo.gv.x - ryo.gv.x1;
            y = ryo.gv.y - ryo.gv.y1;
            if (m == 4) {
                if (ryo.gv.mn.scrollWidth < ryo.gv.mn.parentNode.offsetWidth) return;
                ml = ryo.gv.ml + x;
                a = ryo.gv.mn.parentNode.offsetWidth - ryo.gv.mn.scrollWidth;
                if (ml > 0) ml = 0;
                if (ml < a) ml = a;
                ryo.css(ryo.gv.mn, 'mgl', ml + 'px'); // marginLeft

            } else if (m == 3) {
                if (ryo.gv.mn.scrollHeight < ryo.gv.mn.parentNode.offsetHeight) return;
                mt = ryo.gv.mt + y;
                a = ryo.gv.mn.parentNode.offsetHeight - ryo.gv.mn.scrollHeight;
                if (mt > 0) mt = 0;
                if (mt < a) mt = a;
                ryo.css(ryo.gv.mn, 'mgt', mt + 'px'); // marginTop

            } else if (m == 2) { // move for x
                l2 = ryo.gv.l1 + x;
                a = ryo.gv.mn.parentNode.offsetWidth - 20;
                b = 0 - ryo.gv.mn.offsetWidth + 20;
                if (l2 > a) l2 = a;
                if (l2 < b) l2 = b;
                ryo.css(ryo.gv.mn, 'r', 'auto');
                ryo.css(ryo.gv.mn, 'mgl', '0px');
                ryo.css(ryo.gv.mn, 'l', l2 + 'px');

            } else if (m == 1) { // move for y
                t2 = ryo.gv.t1 + y;
                a = ryo.gv.mn.parentNode.offsetHeight - 20;
                b = 0 - ryo.gv.mn.offsetHeight + 20;
                if (t2 > a) t2 = a;
                if (t2 < b) t2 = b;
                ryo.css(ryo.gv.mn, 'b', 'auto');
                ryo.css(ryo.gv.mn, 'mgt', '0px');
                ryo.css(ryo.gv.mn, 't', t2 + 'px');

            } else { // move for xy
                l2 = ryo.gv.l1 + x;
                a = ryo.gv.mn.parentNode.offsetWidth - 20;
                b = 0 - ryo.gv.mn.offsetWidth + 20;
                if (l2 > a) l2 = a;
                if (l2 < b) l2 = b;
                t2 = ryo.gv.t1 + y;
                c = ryo.gv.mn.parentNode.offsetHeight - 20;
                d = 0 - ryo.gv.mn.offsetHeight + 20;
                if (t2 > c) t2 = c;
                if (t2 < d) t2 = d;
                ryo.css(ryo.gv.mn, 'r', 'auto');
                ryo.css(ryo.gv.mn, 'b', 'auto');
                ryo.css(ryo.gv.mn, 'mg', '0px');
                ryo.css(ryo.gv.mn, 'l', l2 + 'px');
                ryo.css(ryo.gv.mn, 't', t2 + 'px');
            }
        }
    },

    // mouse up
    mu: function(A) {
        var a, b, c, d, w, h, o, x, y;
        A = A || window.event;
        o = A.srcElement || A.target;
        ryo.gv.gsp = new Date().getTime(); // gesture stop
        ryo.gv.mn = null;

        a = o.tagName;
        if (a == 'TEXTAREA' || a == 'INPUT' || ryo.na(o, 'contentEditable') == 'true') {
            ryo.ko.kl = 1;
            ryo.gv.cpObj = o;
        } else ryo.ko.kl = 0;
        if (a == 'A') o.blur();
    },

    // mouse out
    mo: function(A) {
        var a, b, c, d, o;
        A = A || window.event;
        o = A.srcElement || A.target;
        //if(to(ge(), o)) {
        //this.ud.mn = null;
        //}
    },

    // mouse click
    ck: function(A) {
        var a, b, c, d, o;
        A = A || window.event;
        o = A.srcElement || A.target;
    },

    // mouse dblclick
    dk: function(A) {
        var a, b, c, d, o
        A = A || window.event;
        o = A.srcElement || A.target;
    },

    // mouse right key
    mr: function(A) {
        var a, b, c, d, o;
        A = A || window.event;
        o = A.srcElement || A.target;
        if (!o) return;
        if (ryo.gv.ie) A.returnValue = false;
        else A.preventDefault();
    },

    // key down
    kd: function(A) {
        var o, k, K;
        K = A = A || window.event;
        K = K.key || ''
        K = K.toUpperCase();
        o = A.srcElement || A.target;
        k = A.keyCode || A.charCode;
        ryo.ko[K] = 1;
    },

    // key up
    ku: function(A) {
        var f, i, o, k, K, v;
        K = A = A || window.event;
        K = K.key || ''
        K = K.toUpperCase();
        o = A.srcElement || A.target;
        k = A.keyCode || A.charCode;
        if (o.tagName == 'TEXTAREA' || o.tagName == 'INPUT' || ryo.na(o, 'contentEditable') == 'true') ryo.ko.kl = 1;
        else ryo.ko.kl = 0;
        ryo.ko[K] = 0;

        v = K;
        if (ryo.ko.A) v = 'A+' + K;
        else if (ryo.ko.Z) v = 'Z+' + K;
        else if (ryo.ko.D) v = 'D+' + K;
        else if (ryo.ko.CAPSLOCK) v = 'Cap+' + K;
        else if (ryo.ko.A && ryo.ko.S) v = 'A+S+' + K;
        else if (ryo.ko.Z && ryo.ko.S) v = 'Z+S+' + K;
        else if (ryo.ko.CONTROL && ryo.ko.ALT) v = 'Ctr+Alt+' + K;
        else if (ryo.ko.CONTROL) v = 'Ctr+' + K;
        else if (ryo.ko.SHIFT) v = 'Shi+' + K;
        else if (ryo.ko.ALT) v = 'Alt+' + K;
        else if (ryo.ko.META) v = 'Win+' + K;
        else if (ryo.ko.SPACE || ryo.ko[' ']) v = 'Spa+' + K;

        if (ryo.ko.D && v == 'D+F') ryo.ko.kfo = 'DEF';
        if ((ryo.ko.kfo != '无' && ryo.ko.kl == 0) || (ryo.ko.CONTROL || ryo.ko.SHIFT || ryo.ko.ALT)) {
            f = ryo.ko.kf[ryo.ko.kfo][v];
            if(typeof f == 'function') f();
        };
        if (ryo.ko.kl == 2) ryo.ko.kl = 0;

        if (document.activeElement.id == "CMD") {
            // BACKSPACE
            if (k == 8) i = 1;
            else i = 0;
            ryo.cmdi(i);
        }
    },

    // sel key
    sk: function(A) {
        var k;
        A = this.gn(A);
        if (!A) return;
        k = A.getAttribute('kfo');
        if (k) this.ko.kfo = k;
        else this.ko.kfo = 'DEF';
    },

    // key obj
    ko: {
        kl: 0, // key lock
        kfo: 'DEF', // key function obj
        kf: { // key function
            'DEF': {
                'Ctr+ENTER': function() { if(document.activeElement.id == "CMD") ryo.cmd(ryo.gv.cmd.value) },
                'M': function() { ryo.ws("MB", 1) },
                'T': function() { ryo.ws("TB", 1) },
                'S': function() { ryo.nmn("mnNav.spa", "MB"); ryo.ws("MB", 1) },
                'A': function() { ryo.nmn("mnTool.ava", "TB"); ryo.ws("TB", 1) },
                'E': function() { ryo.nmn("mnTool.exp", "TB"); ryo.sn("TB", 1) },
                'C': function() { ryo.gv.cmd.focus() },
            }
        }
    },

    // canvas init
    cvinit: function(A) {
        var a, b, c, d, n, q, z, x, y, w, h, cvs, ctx, inf, that;
        that = this;
        if (WX) {
            wx.createSelectorQuery().select('#CVS').node().exec((res) => {
                cvs = res[0].node;
                ctx = cvs.getContext('2d');
                cvs.width = that.gv.vw;
                cvs.height = that.gv.vh;
                that.gv.cvs.CVS = { cvs: cvs, ctx: ctx, list: [] };
            });

        } else {
            a = ['CVS'];
            for (z = 0; z < a.length; z++) {
                cvs = that.gn(a[z]);
                ctx = cvs.getContext('2d');
                cvs.width = that.gv.vw;
                cvs.height = that.gv.vh;
                that.gv.cvs[a[z]] = { cvs: cvs, ctx: ctx, list: [] };
            }

            console.log(that.gv.vw, that.gv.vh, that.gv.cvs);
            that.gv.cvs.CVS.ctx.beginPath();
            that.gv.cvs.CVS.ctx.fillStyle = '#f22';
            that.gv.cvs.CVS.ctx.rect(10, 10, 820, 24);
            that.gv.cvs.CVS.ctx.fill();
            that.gv.cvs.CVS.ctx.save();
            that.gv.cvs.CVS.ctx.clip();
            //that.gv.cvs.CVS.ctx.stroke();
            that.gv.cvs.CVS.ctx.fillStyle = '#000';
            that.gv.cvs.CVS.ctx.font = '20px Verdana';
            that.gv.cvs.CVS.ctx.textBaseline = 'top';
            c = '中国20px Arial中国abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
            that.gv.cvs.CVS.ctx.fillText(c, 10, 13);
            that.gv.cvs.CVS.ctx.restore();
            console.log(that.gv.cvs.CVS.ctx.measureText(c).width);

            //this.cl();
        }

        //requestAnimationFrame();
        //cancelAnimationFrame();
    },

    // canvas list
    cl: function(A, B, C) {
        var a, b, c, d, x, y, w, h, dw, dh, m, n, o, p, q, r, s, t, z, that, cvs, ctx, fs;
        that = this;
        B = B || 'CVS';
        C = C || this.ud.vmod || 'fall';
        ctx = this.gv.cvs[B].ctx;
        if (!ctx) return;
        if (C == 'map') {
            //a = this.gv.tpl[B][C];
        } else if (C == 'olap') {
            //a = this.gv.tpl[B][C];
        } else if (C == 'fall') {
            //a = this.gv.tpl[B][C];
        } else if (C == 'tile') {
            //a = this.gv.tpl[B][C];
        } else if (C == 'list') {
            //a = this.gv.tpl[B][C];
        }

        o = A;
        o = [{ tit: '测试标题', img: 'pic/license-01.jpg' }, { tit: '测试标题2', img: 'pic/license-01.jpg' }, { tit: '测试标题3', img: 'pic/license-01.jpg' }, { tit: '测试标题4', img: 'pic/license-01.jpg' }];

        a = Date.now();
        for (n = 0; n < 100; n++) {
            //for (m in o[n]) {}
            p = o[0];
            t = p['tit'] + n;
            fs = 20;
            ctx.font = fs + 'px Verdana';
            x = parseInt(this.rr('10-' + (that.gv.vw - 10 - ctx.measureText(t).width)));
            y = parseInt(this.rr('10-' + (that.gv.vh - 10 - (fs + 10))));
            ctx.beginPath();
            ctx.fillStyle = 'rgba(255, 0, 0, 0.3)';
            ctx.rect(x, y, ctx.measureText(t).width + 10, fs + 10);
            ctx.fill();
            ctx.fillStyle = '#000';
            ctx.textBaseline = 'top';
            ctx.fillText(t, x + 5, y + 5 + 1);

            /*q = new Image();
            q.src = p['img'];
            ctx.drawImage(q, 0, 0, that.gv.vw, that.gv.vh);
            r = ctx.getImageData(0, 0, that.gv.vw, that.gv.vh);*/
        }
        b = Date.now();
        console.log('time:', b - a);
    },

    log: function(A) {
        var a, b, c, d, e, f;
        A = A + '';
        a = this.gn('IB');
        b = A.substr(0, 7).toLowerCase();
        f = A.substr(0, 1);
        if (b != '.' && f != '/' && b != 'http:\/\/' && b != 'https:\/') return '';
        c = document.createElement('iframe');
        c.setAttribute('src', 'log.html?url=' + A);
        a.appendChild(c);
        if (a.childNodes.length > 10) a.removeChild(a.firstChild);
    },

    // new page
    npg: function(A, B) {
        var a, b, c, d;
        a = this.rs(10);
        b = this.an(this.gv.tmp, a, 1, 'a');
        if (B) b.download = B;
        this.na(b, 'href', A);
        this.na(b, 'target', '_blank');
        b.click();
    },

    // view ad
    vad: function(A) {
        var a, b, c, d, e, f;
        if (!A) return;
        a = this.na(A, 'lk') || '';
        b = a.substr(0, 1);
        c = a.substr(1);
        d = a.substr(0, 2);
        e = a.substr(2);
        if (b == 't') this.gd('f`vd`tb`dyna`uni.' + c);
        else if (d == 't') this.gd('f`vd`tb`dyna`uni.' + e);
        else this.npg(a);
    },

    msg: function(A, B) {
        var a, b, c, d;
        B = B || 5;
        a = this.gv.tmp;
        if (!a) return;
        a.innerHTML = '<i class="txt" title="' + A + '">' + this.tf(0, 'h:i:s') + ' ' + A + '</i>';
        b = this.gn('MSG');
        b.appendChild(a.firstChild);
        if (b.childNodes.length > 3) b.removeChild(b.firstChild);
        this.sn(b, 'n_', B, 'i_');
    },

    // get date time
    dt: function(A) {
        var y, m, d, h, i, s, w, t, a, b;
        t = new Date();
        if (A) t.setTime(A);
        y = t.getFullYear();
        m = ('0' + (t.getMonth() + 1)).slice(-2);
        d = ('0' + t.getDate()).slice(-2);
        h = ('0' + t.getHours()).slice(-2);
        i = ('0' + t.getMinutes()).slice(-2);
        s = ('0' + t.getSeconds()).slice(-2);
        a = new Date(y, 0, 1);
        b = Math.floor((t - a) / (24 * 60 * 60 * 1000));
        w = Math.ceil((b + (a.getDay() + 1) % 7) / 7);
        return { 'y': y, 'm': m, 'd': d, 'h': h, 'i': i, 's': s, 'w': w };
    },

    // time format
    tf: function(A, B, C) {
        var a, b, c, d, t, y, m, d, h, i, s, y2, m2, d2, h2, i2, s2;
        s2 = 1000;
        i2 = s2 * 60;
        h2 = i2 * 60;
        d2 = h2 * 24;
        m2 = d2 * 30;
        y2 = m2 * 365;
        a = new Date();
        b = a.getTime();
        if (!A) A = b;
        if (((b + '').length - (A + '').length) == 3) A = A + '000';
        A = parseInt(A) || 0;
        B = B || 'y-m-d h:i:s';
        c = b - A;
        if (C) { // 在指定时段内输出时间差
            if (c >= y2) t = Math.floor(c / y2) + '年前';
            else if (c >= m2) t = Math.floor(c / m2) + '个月前';
            else if (c >= d2) t = Math.floor(c / d2) + '天前';
            else if (c >= h2) t = Math.floor(c / h2) + '小时前';
            else if (c >= i2) t = Math.floor(c / i2) + '分钟前';
            else t = Math.floor(c / s2) + '秒钟前';
        } else {
            a.setTime(A);
            y = a.getFullYear();
            m = ('0' + (a.getMonth() + 1)).slice(-2);
            d = ('0' + a.getDate()).slice(-2);
            h = ('0' + a.getHours()).slice(-2);
            i = ('0' + a.getMinutes()).slice(-2);
            s = ('0' + a.getSeconds()).slice(-2);

            t = B;
            t = t.replace('y', y);
            t = t.replace('m', m);
            t = t.replace('d', d);
            t = t.replace('h', h);
            t = t.replace('i', i);
            t = t.replace('s', s);
        }
        return t;
    },

    // localStorage, B value: undefined=get, false=delete, null=clear, else set
    ls: function(A, B) {
        var a, b, c, d;
        a = window.localStorage;
        if (B === undefined) {
            return a.getItem(A);
        } else if (B === false) {
            a.removeItem(B);
        } else if (B === null) {
            a.clear();
        } else {
            a.setItem(A, B);
        }
    },

    // indexDB, C value: undefined=get, false=delete, null=clear, true=delDB, else set
    idb: function(A, B, C) {
        var a, b, c, d, i, r, s, t, v, odb, db, that;
        that = this;
        that = this;
        v = '';
        i = window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB;
        odb = i.open(that.ini.prefix + 'IDB', 1);
        //console.log(odb);
        odb.onupgradeneeded = function(e) {
            db = e.target.result;
            //console.log('openDB Upgrading');
            if (!db.objectStoreNames.contains('sobj')) {
                db.createObjectStore('sobj', { keyPath: 'id' }); // {keyPath: keyName, autoIncrement: true}
            }
        };
        odb.onsuccess = function(e) {
            db = e.target.result;
            //console.log('openDB Success');
            t = db.transaction('sobj', 'readwrite'); // readonly, readwrite
            s = t.objectStore('sobj');
            //console.log(s);

            if (C === undefined) {
                r = s.get(A);
                //console.log('get', A, r);
            } else if (C === false) {
                r = s.delete(A);
            } else if (C === null) {
                r = s.clear();
            } else if (C === true) {
                r = i.deleteDatabase(that.ini.prefix + 'IDB');
            } else {
                r = s.put({ id: A, ctt: C });
                //console.log('put', A, r);
            }

            r.onsuccess = function(e) {
                //console.log('success-exe', r);
                if (C === undefined && r.result && r.result.ctt) v = r.result.ctt;
            };
            r.onerror = function(e) {
                console.log('error-exe', e.target.error.name);
            };
            t.oncomplete = function(e) {
                //console.log('oncomplete', v);
                db.close();
                if (typeof B == 'function') B(v);
            };
            t.abort = function(e) {
                console.log('abort');
                db.close();
            };
            t.error = function(e) {
                console.log('error');
                db.close();
            };
        };
        odb.onerror = function(e) {
            console.log('openDB Error');
            console.dir(e);
            db.close();
        };
    },

    xhr: function() {
        var a, b, z;
        if (typeof XMLHttpRequest != 'undefined') {
            a = new XMLHttpRequest();
        } else if (window.ActiveXObject) {
            b = ['Msxml2.XMLHttp.5.0', 'Msxml2.XMLHttp.4.0',
                'Msxml2.XMLHttp.3.0', 'Msxml2.XMLHttp', 'Microsoft.XMLHttp'
            ];
            for (z = 0; z < b.length; z++) {
                try {
                    a = new ActiveXObject(b[z]);
                    break;
                } catch (e) {
                    return null;
                }
            }
        }
        return a;
    },

    // request
    req: function(A, B) {
        var a, b, c, d, e, f, i, s, t, p, obj, that;
        that = this;
        obj = this.obj(A);
        //console.log(obj);
        if (!obj['f']) return this.msg('未知命令！');
        if (obj['f'] == 'init') {
            i = this.ls(this.ini.prefix + 'CID') || '';
            t = this.ls(this.ini.prefix + 'CTAG') || '';
            p = this.ud.ctp || '';
            if (i) obj['cid'] = i;
            if (t) obj['ctag'] = t;
            if (p) obj['ctp'] = p;
        } else if (obj['f'] == 'reg' && this.ud.inv) {
            obj['inv'] = this.ud.inv;
        }
        //obj['s'] = 'req';
        //obj['dp'] = '';
        s = this.obj(obj, 2, 1);
        //console.log(s);
        if (this.ini.enc == 1) s = 'ENCB64' + this.b64(s, 1, 1);
        else s = this.e36(s);

        a = this.xhr();
        if (!a) return this.msg('xhr error!');
        a.open('POST', 'api?t=' + Date.now(), true);
        a.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');

        a.onreadystatechange = function() {
            if (a.readyState == 4 && a.status == 200) {
                if (a.responseText != '') {
                    c = a.responseText;
                    d = c.substr(0, 6);
                    if (d == 'ENCB64') c = b64(c.substr(6), 2, 1);
                    else c = that.e36(c, 2);
                    c = JSON.parse(c);
                    if (c.errmsg) that.msg(c.errmsg);
                    if (that[c.back]) {
                        that[c.back](c.data);
                    }
                    //console.log(c);
                }
            } else if (a.readyState == 4 && a.status == 304 && B == 2) {
                that.msg('304');
            } else if (a.readyState == 4 && a.status == 404 && B == 2) {
                that.msg('404 Not Found');
            }
        };

        a.send('d=' + s);
    },

    // response
    res: function(A) {
        var o, z;
        o = this.obj(A);
        if (o.func) {
            for (z == 0; z < o.func.length; z++) {
                if (this[o.func[z].fn]) this[o.func[z].fn](o.func[z].fp);
            }
        }

    },

    nodata: function(A) {
        var n = this.gn(A);
        console.log(n);
        if (n) n.innerHTML = '<i class="msg">查无数据！</i>';
        return this.msg('查无数据！');
    },

    // command
    cmd: function(A) {
        var a, b, c, c2, d, d2, e, f, g, h, i, j, k, l, o, p, q, r, s, t, u, v, x, y, z, help, admin;
        a = (A || '').trim();
        //console.log(A);
        b = a.toLowerCase();
        if (b == 'hide') {
            this.cmdv('');
            return this.msg('已启用密码模式');
        } else if (b == 'show') {
            this.cmdv('');
            return this.msg('已禁用密码模式');
        }

        help = '命令行可以通过输入命令加参数名值对(键值)进行操作，如登录命令和参数可以这样编辑：lgn .n 用户名 .p 用户密码。还可以用没有参数名只有参数值的格式(列值)操作，如：lgn 用户名 用户密码。如果参数比较多的话建议用名值的格式操作，输入英文问号(?)加命令名提交可查看此命令的简单介绍，输入双英文问号(??)加命令名提交可查看此命令的详细介绍及使用示例，注意事项：列值格式如果参数值有空格且不是最后一个参数请用S.代替空格，名值格式如果参数值有空格+点号请用D.代替点号。以下是常用命令: !z!z查看用户: /用户名!z!z注册: reg .n 用户名 .p 用户密码!z!z登录: lgn .n 用户名 .p 用户密码!z!z退出登录: lgt !z!z转账: ta .t 转账类型(uu=用户相互转账,wu=微信充值到用户,au=支付宝充值到用户,bu=银行卡充值到用户,pu=贝宝充值到用户,uw=用户提现到微信,ua=用户提现到支付宝,ub=用户提现到银行卡,up=用户提现到贝宝) .s 转账金额 .n 目标用户(用户相互转账需提交目标用户名)!z!z修改用户名: mn .t 名称类型(1=昵称,2=用户名) .n 新名称!z!z修改用户头像: ma .u 用户头像地址(sys=系统随机头像)!z!z修改用户信息: mi .g 性别(1=男性,2=女性) .a 年龄 .b 生日(月日,格式=xxxx,如:0201)!z!z修改个人简介: mp .d 个人格言 .p 个人简介!z!z修改媒体账号: mm .wn 微博昵称 .wl 微博链接 .dn 抖音昵称 .dl 抖音链接 .xn 西瓜昵称 .xl 西瓜链接 .tn 腾讯昵称 .tl 腾讯链接 .o 其它账号!z!z修改安全信息: ms .m 修改类型(f=找回密码,u=用户密码,t=支付密码,s=安全码,e=邮箱,m=手机号,w=微信号,a=支付宝,p=贝宝,b=银行卡号) .v 验证类型(t=交易密码验证,s=安全码验证,e=邮箱验证,m=短信验证.PS:用微信登录的新注册用户请通过ip命令查看自己的初始密码并即时修改初始密码) .c 验证码 .n 新值 .u 用户名(找回密码时需要提交此参数)!z!z生活动态: dyna .a 动态类目 .t 动态内容!z!z游戏动态: game .g 游戏标识 .c 内容类型(1=游戏活动,2=游戏公告,3=游戏帮助,4=游戏攻略,5=游戏教学,6=游戏问答,7=游戏组队,8=游戏打卡) .t 动态内容!z!z添加游戏: ngm .t 平台类型(0=手游,1=端游,2=页游,3=街机) .a 游戏类目(0=角色,1=动作,2=竞技,3=冒险,4=养成,5=休闲,6=策略) .i 游戏名称 .l 游戏链接 .s 游戏大小 .p 师傅奖励 .g 师祖奖励 .t 游戏介绍!z!z发布招工: job .p 工作类型(0=日结,1=周结) .c 职位数量 .m 工作时薪 .a 工作类目 .t 工作内容!z!z添加商店: shop .n 商店名称 .t 商店类型(0=网店,1=门店,2=货摊) .a 商店类目!z!z添加商品: gds .s 商店标识 .a 商品类目 .i 商品标题 .d 商品详情 .c 商品配置!z!z添加广告: adv .s 广告状态 .t 广告类型 .p 广告价格 .i 广告标题 .l 广告链接 .c 广告图片!z!z随机字串: rs .l 字串长度 .t 输出类型(n=数字,l=小写,u=大写,nl=数字+小写,nu=数字+大写,lu=小写+大写,nlu=默认值:数字+大小写字母)!z!z特殊符号编码或解码: e36 .s 字串内容 .t 操作类型(1=编码,2=解码)!z!zbase64编码或解码: b64 .s 字串内容 .t 操作类型(1=编码,2=解码)!z!zmd5加密: md5 .s 字串内容!z!zsha加密: sha .s 字串内容 .t 操作类型(1=sha1(字符长度=40),2=sha256(字符长度=64,默认),3=sha512(字符长度=128))';

        admin = '新建数据库: newdb .s 数据库服务器 .u 数据库用户名 .p 数据库用户密码 .d 数据库名 .w 数据密码!z!z添加数据库: adb .p 数据密码 .n 数据库名!z!z删除数据库: ddb .p 数据密码 .n 数据库名!z!z列出数据库: ldb .p 数据密码 .n 数据库名!z!z添加数据表: atb .p 数据密码 .t 数据表 .d 是否删除旧表!z!z删除数据表: dtb .p 数据密码 .t 数据表!z!z列出数据表: ltb .p 数据密码 .n 数据库名!z!z添加字段: ac .p 数据密码 .t 数据表 .n 字段名 .a 在该字段后插入 .d 数据类型 .l 数据长度 .c 字段注释!z!z删除字段: dc .p 数据密码 .t 数据表 .n 字段名!z!z编辑字段: ec .p 数据密码 .t 数据表 .n 字段名 .a 在该字段后插入 .d 数据类型 .l 数据长度 .c 字段注释!z!z列出字段: lc .p 数据密码 .t 数据表!z!z添加索引: ai .p 数据密码 .t 数据表 .c 字段名 .i 索引名 .y 索引类型!z!z删除索引: di .p 数据密码 .t 数据表 .i 索引名!z!z列出索引: li .p 数据密码 .t 数据表!z!z备份数据: bd .p 数据密码 .t 数据表 .f 文件名 .c 备份字段 .b 备份类型!z!z恢复数据: rd .p 数据密码 .t 数据表 .f 文件名!z!z添加数据: ad .t 数据表 .v 字段值(v代表任意键名)!z!z删除数据: dd .t 数据表 .k 关键词!z!z编辑数据: ed .t 数据表 .k 关键词 .v 字段值(v代表任意键名)!z!z列出数据: ld .t 数据表 .k 关键词(字段名(c=cat,t=tag,i=tit,u=un,n=uni,l=lg,b=ba,a=aa,o=ac,g=gen,e=age,r=rc,p=rpa)+.+关键词) .o 排序方式(字段名+.+数字(1=升序,2=降序),默认值=id.2) .n 查询页码 .r 每页笔数';

        o = {};
        p = {};
        q = ',dyna,game,ngm,job,shop,gds,';

        r = {
            reg: ['un', 'up'],
            lgn: ['un', 'up'],
            ta: ['ttp', 'sum', 'un'],
            mn: ['tp', 'new'],
            ma: ['src'],
            mi: ['gen', 'age', 'bir'],
            mp: ['dic', 'pro'],
            mm: ['wbnick', 'wburl', 'dynick', 'dyurl', 'xgnick', 'xgurl', 'txnick', 'txurl', 'other'],
            ms: ['mt', 'vt', 'vc', 'new', 'un'],
            svc: ['vt'],
            bdyx: ['ga'],
            dyna: ['cat', 'ctt'],
            game: ['guni', 'ctp', 'ctt'],
            ngm: ['ptp', 'cat', 'tit', 'lk', 'fs', 'prp', 'grp', 'ctt'],
            job: ['jtp', 'jct', 'jmn', 'cat', 'tit'],
            shop: ['sn', 'stp', 'cat'],
            gds: ['suni', 'cat', 'tit', 'dt', 'con'],
            adv: ['sta', 'atp', 'pri', 'tit', 'link', 'pic'],
            rs: ['len', 'tp'],
            e36: ['str', 'tp', 'not'],
            b64: ['str', 'tp', 'pw'],
            md5: ['str'],
            sha: ['str', 'tp'],
            newdb: ['sv', 'un', 'up', 'dn', 'dp'],
            adb: ['dp', 'dn'],
            ddb: ['dp', 'dn'],
            ldb: ['dp', 'dn'],
            atb: ['dp', 'tb', 'del'],
            dtb: ['dp', 'tb'],
            ltb: ['dp', 'dn'],
            ac: ['dp', 'tb', 'cn', 'aft', 'dt', 'len', 'cmt'],
            dc: ['dp', 'tb', 'cn'],
            ec: ['dp', 'tb', 'cn', 'aft', 'dt', 'len', 'cmt'],
            lc: ['dp', 'tb'],
            ai: ['dp', 'tb', 'cn', 'in', 'it'],
            di: ['dp', 'tb', 'in'],
            li: ['dp', 'tb'],
            bd: ['dp', 'tb', 'fn', 'bc', 'bt'],
            rd: ['dp', 'tb', 'fn'],
            ad: ['tb', 'cv'],
            dd: ['tb', 'kw'],
            ed: ['tb', 'kw', 'cn', 'cv'],
            ld: ['tb', 'kw', 'od', 'pn', 'pr']
        };

        s = {
            reg: {
                n: 'un',
                p: 'up'
            },
            lgn: {
                n: 'un',
                p: 'up'
            },
            ta: {
                t: 'ttp',
                s: 'sum',
                n: 'un'
            },
            mn: {
                t: 'tp',
                n: 'new'
            },
            ma: {
                u: 'url'
            },
            mi: {
                g: 'gen',
                a: 'age',
                b: 'bir'
            },
            mp: {
                d: 'dic',
                p: 'pro'
            },
            mm: {
                wn: 'wbnick',
                wl: 'wburl',
                dn: 'dynick',
                dl: 'dyurl',
                xn: 'xgnick',
                xl: 'xgurl',
                tn: 'txnick',
                tl: 'txurl',
                o: 'other'
            },
            ms: {
                m: 'mt',
                v: 'vt',
                c: 'vc',
                n: 'new',
                u: 'un'
            },
            svc: {
                t: 'vt'
            },
            dyna: {
                a: 'cat',
                t: 'ctt'
            },
            game: {
                g: 'guni',
                c: 'ctp',
                t: 'ctt'
            },
            ngm: {
                t: 'ptp',
                a: 'cat',
                i: 'tit',
                l: 'lk',
                s: 'fs',
                p: 'prp',
                g: 'grp',
                t: 'ctt'
            },
            job: {
                p: 'jtp',
                c: 'jct',
                m: 'jmn',
                a: 'cat',
                t: 'tit'
            },
            shop: {
                n: 'sn',
                t: 'stp',
                a: 'cat'
            },
            gds: {
                s: 'suni',
                a: 'cat',
                i: 'tit',
                d: 'dt',
                c: 'con'
            },
            adv: {
                s: 'sta',
                t: 'atp',
                p: 'pri',
                i: 'tit',
                l: 'link',
                c: 'pic'
            },
            rs: {
                l: 'len',
                t: 'tp'
            },
            e36: {
                s: 'str',
                t: 'tp',
                n: 'not'
            },
            b64: {
                s: 'str',
                t: 'tp',
                p: 'pw'
            },
            md5: {
                s: 'str'
            },
            sha: {
                s: 'str',
                t: 'tp'
            },
            newdb: {
                s: 'sv',
                u: 'un',
                p: 'up',
                d: 'dn',
                w: 'dp'
            },
            adb: {
                p: 'dp',
                n: 'dn'
            },
            ddb: {
                p: 'dp',
                n: 'dn'
            },
            ldb: {
                p: 'dp',
                n: 'dn'
            },
            atb: {
                p: 'dp',
                t: 'tb',
                d: 'del'
            },
            dtb: {
                p: 'dp',
                t: 'tb'
            },
            ltb: {
                p: 'dp',
                n: 'dn'
            },
            ac: {
                p: 'dp',
                t: 'tb',
                n: 'cn',
                a: 'aft',
                d: 'dt',
                l: 'len',
                c: 'cmt'
            },
            dc: {
                p: 'dp',
                t: 'tb',
                n: 'cn'
            },
            ec: {
                p: 'dp',
                t: 'tb',
                n: 'cn',
                a: 'aft',
                d: 'dt',
                l: 'len',
                c: 'cmt'
            },
            lc: {
                p: 'dp',
                t: 'tb'
            },
            ai: {
                p: 'dp',
                t: 'tb',
                c: 'cn',
                i: 'in',
                y: 'it'
            },
            di: {
                p: 'dp',
                t: 'tb',
                i: 'in'
            },
            li: {
                p: 'dp',
                t: 'tb'
            },
            bd: {
                p: 'dp',
                t: 'tb',
                f: 'fn',
                c: 'bc',
                b: 'bt'
            },
            rd: {
                p: 'dp',
                t: 'tb',
                f: 'fn'
            },
            ad: {
                t: 'tb',
                v: 'cv'
            },
            dd: {
                t: 'tb',
                k: 'kw'
            },
            ed: {
                t: 'tb',
                k: 'kw',
                n: 'cn',
                v: 'cv'
            },
            ld: {
                t: 'tb',
                k: 'kw',
                o: 'od',
                n: 'pn',
                r: 'pr'
            }
        };

        t = {
            ',zc,': 'reg',
            ',dl,': 'lgn',
            ',tc,': 'lgt',
            ',zz,': 'ta',
            ',gm,': 'mn',
            ',tx,': 'ma',
            ',xx,': 'mi',
            ',jj,': 'mp',
            ',mt,': 'mm',
            ',aq,': 'ms',
            ',rz,': 'cer',
            ',c,lt,': 'chat',
            ',d,dt,': 'dyna',
            ',g,yx,': 'game',
            ',ng,xyx,': 'ngame',
            ',j,zp,zg/gz,': 'job',
            ',s,sd,': 'shop',
            ',o,sp,': 'gds',
            ',gg,': 'adv',
            ',tj,': 'ad',
            ',sc,': 'dd',
            ',xg,': 'ed',
            ',cx,': 'ld',
            ',y,yzm,': 'svc',
            ',r,sj,': 'rs',
            ',e,3,36,zf,': 'e36',
            ',b,6,64,': 'b64',
            ',m,5,': 'md5'
        };

        e = a.substr(0, 3);
        f = (this.gv.hpass || '').substr(0, 3);
        if (e == '***' && (f == 'reg' || f == 'lgn')) a = this.gv.hpass;
        b = a;
        c = b.substr(0, 1);
        c2 = b.substr(0, 2);
        d = (b.substr(1) || '').trim();
        d2 = (b.substr(2) || '').trim();
        if (a == '?' || a == '？') {
            this.vc('<i class="tit">指令器帮助教程</i>' + this.e36(help.replace(/\!z/g, '<br>'), 2), 'dyna');
            this.cmdv('');
            return;
        } else if (a == 'admin') {
            this.vc('<i class="tit">指令器帮助教程(管理员)</i>' + this.e36(admin.replace(/\!z/g, '<br>'), 2) + '</i>', 'dyna');
            this.cmdv('');
            return;
        } else if ((c2 == '??' || c2 == '？？') && help.indexOf(': ' + d2 + ' ') > 0) {
            this.gd('f`ld`tb`dyna`kw`ctp.1,i.CMD Help: ' + d2);
            this.cmdv('');
            return;
        } else if (c == '?' || c == '？') {
            if (d == '/') {
                this.cmdv('/用户名');
                return;
            } else if (help.indexOf(': ' + d + ' ') > 0) {
                g = help.split(': ' + d + ' ');
                h = (g[1] || '').split('!z!z');
                this.cmdv(d + ' ' + this.e36(h[0] || '', 2));
                return;
            } else if (admin.indexOf(': ' + d + ' ') > 0) {
                g = admin.split(': ' + d + ' ');
                h = (g[1] || '').split('!z!z');
                this.cmdv(d + ' ' + this.e36(h[0] || '', 2));
                return;
            }
        } else if (a == 'ip' || a == 'lgt' || a == 'qrpop') {
            o.f = a;
            this.req(o);
            this.cmdv('');
            return;
        }

        i = new RegExp('\\s+\\.\\w+\\s+', 'g');
        e = b.match(/\s+\.\w+\s+/g);
        f = b.split(i);
        p.f = (f.shift() || '').trim();
        //console.log(b, i, e, f, p.f);

        if (!e) { // 列值格式
            g = b.indexOf(' ');
            k = b.substr(0, g);
            b = b.substr(g + 1);
            for (z in t) {
                if (z.indexOf(',' + k + ',') != -1) k = t[z];
            }
            if (r[k]) {
                if (k == 'ad' || k == 'ed') return this.msg('ad 和 ed 命令只能用名值格式执行。')
                o.f = k;
                u = 1;
                v = 0;
                if (k == 'reg' || k == 'lgn' || k == 'mn' || k == 'mp' || k == 'dyna ' || k == 'shop') v = 2;
                else if (k == 'mi' || k == 'game ') v = 3;
                else if (k == 'gds') v = 4;
                for (z = 0; z < r[k].length; z++) {
                    b = b.trim();
                    g = b.indexOf(' ');
                    h = b.substr(0, g);
                    if (g <= 0) {
                        if (b) {
                            b = this.e36(b);
                            if (b != '!q') o[r[k][z]] = b;
                        }
                        if (v && z < r[k].length - 1) u = 0;
                        break;
                    } else {
                        if (z >= r[k].length - 1) {
                            b = this.e36(b);
                            if (b != '!q') o[r[k][z]] = b;
                            break;
                        }
                        if (h) {
                            h = this.e36(h);
                            if (h != '!q') o[r[k][z]] = h;
                        }
                        b = b.substr(g + 1);
                    }
                }
                if (!u) return this.msg('命令参数不合格！');
            } else if (a == 'lgt' || a == 'ip' || a == 'rs' || a == 'qrpop' || a == 'updqr') {
                o.f = a;
            }

        } else { // 键值格式

            for (z = 0; z < e.length; z++) {
                k = (e[z] || '').trim().substr(1);
                v = this.e36((f[z] || '').trim());
                if (v == '!q') continue;
                p[k] = v;
            }

            for (z in t) {
                if (z.indexOf(',' + p.f + ',') != -1) p.f = t[z];
            }

            for (z in p) {
                if (z == 'f') {
                    o[z] = p[z];
                    continue;
                }
                if (s[p.f] && s[p.f][z]) o[s[p.f][z]] = p[z];
                else o[z] = p[z];
            }
        }
        //console.log(o, p);

        if (p.f == 'ta') {
            p.oid = this.ud.wx_opid || '';
            if (this.ini.ismob || this.pgobj) p.ptp = 'js';
            else p.ptp = 'nat';
        }

        if (o.f == 'rs') {
            s = this.rs(parseInt(this.e36(o.len || 6, 2)), this.e36(o.tp, 2).trim());
            this.cmdv(s);
            return;
        } else if (o.f == 'e36') {
            s = this.e36(this.e36(o.str || '', 2), parseInt(o.tp || 1) || 1);
            this.cmdv(s);
            return;
        } else if (o.f == 'b64') {
            s = this.b64(this.e36(o.str || '', 2), parseInt(o.tp || 1) || 1, this.e36(o.pw || '', 2));
            this.cmdv(s);
            return;
        } else if (o.f == 'md5') {
            s = this.md5(this.e36(o.str || '', 2));
            this.cmdv(s);
            return;
        } else if (o.f == 'sha') {
            s = this.sha(this.e36(o.str || '', 2), parseInt(o.tp || 2) || 2);
            this.cmdv(s);
            return;
        } else if ((o.f == 'ad' || o.f == 'ed') && o.ctt) {
            i = this.tit(o.ctt) || '';
            o.tit = i;
            i = this.tag(o.ctt) || '';
            o.tag = i;
            i = this.pic(o.ctt) || '';
            o.pv = i;
            i = o.ctt.substr(0, 120);
            o.des = i;
            this.req(o);
        } else if (o.f) {
            if (q.indexOf(',' + o.f + ',') != -1) {
                o.tb = o.f.replace('ngame', 'game');
                o.f = 'ad';
            }
            //console.log(o);
            if (o.f == 'ld') this.gd(o);
            else this.req(o);
        } else if (c == '/' && d) {
            s = 'f`vd`tb`user`kw`un.' + d;
            this.gd(s);
        } else if (a) {
            g = this.ini.cc || 'dyna';
            s = 'f`ld`tb`' + g + '`kw`t.' + a;
            this.gd(s);
        } else {
            this.msg('未知命令！');
        }
        this.cmdv('');
    },

    // set cmd value
    cmdv: function(A) {
        this.gv.cmd.value = A || '';
    },

    // cmd focus
    cmdf: function(A) {
        var a, b, c, d, n;
        a = this.gv.cmd.value || '';
        b = a.split(/\r\n|\r|\n/);
        c = this.gn('EB').className || '';
        if (b.length > 1) {
            if (c.indexOf('i_') > -1 || c.indexOf('f_') > -1) {
                this.ws('EB', 'n_');
            }
        } else if (c.indexOf('a_') < 0 && c.indexOf('n_') < 0) {
            this.ws('EB', 'f_');
        }
        if (a == '') {
            this.gv.cmd.setAttribute('placeholder', '输入问号(?)查看帮助');
        }
    },

    // cmd blur
    cmdb: function(A) {
        var a, b, c, d;
        a = this.gv.cmd.value || '';
        if (a == '') {
            this.gv.cmd.setAttribute('placeholder', '?');
            this.ws('EB', 'i_');
        }
    },

    // cmd insert
    cmdi: function(A) {
        var a, b, c, d, e, f, l, n, s, t, z;
        a = this.gv.cmd.value || '';
        b = a.split(/\r\n|\r|\n/);
        c = this.gn('EB').className || '';
        if (b.length > 1) {
            if (c.indexOf('i_') > -1 || c.indexOf('f_') > -1) {
                this.ws('EB', 'n_');
            }
        } else if (c.indexOf('a_') < 0 && c.indexOf('n_') < 0) {
            this.ws('EB', 'f_');
        }

        if (a.trim().toLowerCase() == 'hide') this.gv.ishide = 1;
        if (a.trim().toLowerCase() == 'show') this.gv.ishide = 0;
        t = this.gv.hpass || '';
        l = t.length - 1;
        if (l < 0) l = 0;
        if (a.length < 4 && a.indexOf('*') < 0) this.gv.hpass = t = a;
        else if (A == 1) this.gv.hpass = t = t.substr(0, l);
        else if (a.length - t.length == 1) this.gv.hpass = t += a.slice(-1);
        e = t.substr(0, 3);
        if (this.gv.ishide && (e == 'reg' || e == 'lgn')) {
            s = [];
            for (z = 0; z < t.length; z++) {
                s.push('*');
            }
            this.gv.cmd.value = s.join('');
        } else if (this.gv.ishide && a.length < 4 && a.indexOf('*') != -1) {
            this.gv.cmd.value = t;
        }
        //console.log(a, t, e);
    },

    // format command
    fc: function(A) {
        var a, b, c, d, e, f, k, o, s, t, z;
        a = parseInt(this.ini.pnx) || 100;
        b = parseInt(this.ini.pr) || 40;
        c = parseInt(this.ini.prx) || 100;
        if (b < 1) b = 1;
        if (b > c) b = c;
        A = A || '';

        if (!A) return {
            cmd: '',
            msg: this.msg('未知命令！')
        };
        t = {
            'd': 'dyna',
            'p': 'pic',
            'a': 'ado',
            'v': 'vdo',
            'f': 'file',
            's': 'shop',
            'g': 'gds',
            'dc': 'dcmt',
            'pc': 'pcmt',
            'ac': 'acmt',
            'vc': 'vcmt',
            'fc': 'fcmt',
            'cc': 'ccmt',
            'r': 'rel',
            'u': 'uc',
            'g': 'gc',
            'gu': 'gu',
            'gg': 'adv',
            'e': 'exp',
            'o': 'top',
            'pp': 'prop',
            'kp': 'knap'
        };

        o = this.obj(A);
        if (o.f == 'ld') {
            o.tb = o.tb || this.ini.cc || 'dyna';
            o.kw = o.kw || ''; // keyword
            o.kw = this.fk(o.kw, o.tb);
            if (!o.od && o.kw) {
                if (this.ini.helpasc == 1 && o.kw.indexOf('cat.help') != -1) o.od = 'id.1';
                else if (this.ini.cmdhelpasc == 1 && o.kw.indexOf('cat.cmdhelp') != -1) o.od = 'id.1';
            }
            o.od = o.od || 'id.2'; // order
            o.od = this.fo(o.od);
            o.pn = parseInt(o.pn) || 1; // page number
            o.pr = parseInt(o.pr) || b; // page row
            if (!o.pn > a) return {
                cmd: '',
                msg: this.msg('页码超限！')
            };

        }

        o.f = o.f || '';
        o.tb = o.tb || '';
        o.kw = o.kw || '';
        o.od = o.od || 'id.2';
        o.pn = o.pn || 1;
        o.pr = o.pr || 40;
        o.ctn = o.ctn || (o.f == 'vd' ? o.tb + 'Ctt' : o.tb + '_' + o.pn);
        o.tpl = o.tpl || (o.f == 'vd' ? o.tb + 'Ctt' : o.tb);
        if (o.f == 'vd') s = 'f`' + o.f + '`tb`' + o.tb + '`kw`' + o.kw + '`ctn`' + o.ctn + '`tpl`' + o.tpl;
        else s = 'f`' + o.f + '`tb`' + o.tb + '`kw`' + o.kw + '`od`' + o.od + '`pn`' + o.pn + '`pr`' + o.pr + '`ctn`' + o.ctn + '`tpl`' + o.tpl;
        return {
            cmd: s,
            msg: ''
        };
    },

    // format keyword
    fk: function(A, B) {
        var a, b, c, d, e, f, g, h, i, j, k, m, o, s, t, w, y, z, dt;
        A = A || '';
        if (!A) return '';
        A = A.toLowerCase();
        A = A.replace(/\!q/g, ',');
        A = A.replace(/\!r/g, '.');
        B = B || 'dyna';
        t = {
            'c': 'cat',
            't': 'tag',
            'i': 'tit',
            'u': 'un',
            'ru': 'run',
            'n': 'uni',
            'l': 'lg',
            'b': 'ba',
            'a': 'aa',
            'o': 'ac',
            'g': 'gen',
            'e': 'age',
            'r': 'rc',
            'p': 'rpa'
        };
        o = {};
        k = {};
        a = A.split(',');
        for (z = 0; z < a.length; z++) {
            b = (a[z] || '').split('.');
            if (b.length < 2 || !b[0] || !b[1]) continue;
            if (t[b[0]]) b[0] = t[b[0]];
            o[b[0]] = b[1];
        }
        //console.log(A, B, o);

        c = this.obj(this.ud.set) || {}; // user setting
        d = ',' + (this.ini.wtb || '') + ',';
        e = (this.ini.wcl || '').split(',');

        if (d.indexOf(',' + B + ',') != -1) {
            for (z = 0; z < e.length; z++) {
                if (o[e[z]]) k[e[z]] = o[e[z]];
                else if (c[e[z]]) k[e[z]] = c[e[z]];
            }
        }
        //console.log(o, k);

        if (B == 'top') {
            dt = this.dt();
            y = dt.y;
            m = dt.m;
            d = dt.d;
            w = dt.w;
            //console.log(k, y, m, d, w);

            k['dt'] = k['dt'].toLowerCase();
            if (k['dt'] == 'w') {
                k['dt'] = 'W' + y + w;
            } else if (k['dt'] == 'd') {
                k['dt'] = 'D' + y + m + d;
            } else if (k['dt'] == 'm') {
                k['dt'] = 'M' + y + m;
            } else if (k['dt'] == 'y') {
                k['dt'] = 'Y' + y;
            } else {
                k['dt'] = 'M' + y + m;
            }
        }

        s = [];
        for (z in k) {
            s.push(z + '.' + k[z]);
        }
        s = s.join(',');
        return s;
    },

    // format order
    fo: function(A) {
        var a, b, c, d, o, z;
        A = A || '';
        A = A.toLowerCase();
        A = A.replace(/\!r/g, '.');
        c = {
            'i': 'id',
            'r': 'rh',
            'v': 'vict',
            'c': 'coct',
            'p': 'prct',
            'f': 'fact',
            'u': 'un',
            'n': 'nn',
            'a': 'age',
            'ml': 'ml',
            'ul': 'ul',
            'rl': 'rl',
            'cl': 'cl'
        };
        d = [];
        for (z in c) {
            d.push(c[z]);
        }
        d = ',' + d.join(',') + ',';
        o = {};
        a = A.split('.');
        a[0] = (a[0] || '').trim();
        if (c[a[0]]) a[0] = c[a[0]];
        if (d.indexOf(',' + a[0] + ',') < 0) a[0] = 'id';
        a[1] = parseInt(a[1]) || 1;
        b = a[0] + '.' + a[1];
        return b;
    },

    // get title
    tit: function(A) {
        var a, b, c, d;
        if (!A) return '';
        a = A.substr(0, 60);
        a = a.trim();
        a = a.replace(/\r\n/g, '!z');
        a = a.replace(/\n/g, '!z');
        b = a.split('!z');
        return b[0] || '';
    },

    // get tag
    tag: function(A) {
        var a, b, c, d, n, p, z;
        if (!A) return '';
        A = this.e36(A, 2);
        a = A.split('#');
        b = a.length;
        c = [];
        n = 0;
        for (z = 1; z < b; z++) {
            p = a[z].indexOf(' ');
            if (p > 0) {
                d = a[z].substr(0, p);
                if (d && d.length > 1 && d.length < 26) {
                    c.push(d);
                    if (++n >= 5) break;
                }
            }
        }
        if (c.length > 0) c = ',' + c.join(',') + ',';
        else c = '';
        return c;
    },

    // get picture
    pic: function(A) {
        var a, b, c, d, n, p, z;
        A = this.e36(A, 2);
        a = A.split('P.');
        b = a.length;
        c = [];
        n = 0;
        for (z = 1; z < b; z++) {
            p = a[z].indexOf(' ');
            if (p > 0) {
                d = a[z].substr(0, p);
                d = d.trim();
                c.push('"' + d + '"');
                if (++n >= 9) break;
            }
        }
        if (c.length > 0) c = '{"pics":[' + c.join(',') + ']}';
        else c = '';
        return c;
    },

    // get data
    gd: function(A) {
        var a, b, c, d, o, s, t, cmd, ctn, that;
        that = this;
        t = '';
        o = this.fc(A);
        //console.log(A, o);
        if (o.msg) return o.msg;
        cmd = o.cmd || '';
        this.idb(that.md5(this.ini.prefix + cmd), function(val) {
            s = that.e36(val, 2) || '{}';
            o = JSON.parse(s) || {};
            a = parseInt(o.tm) || 0;
            b = that.ini.dbexp || {};
            c = b[o.tb] || 0; // 各数据表数据有效分钟数
            //console.log(cmd, a, b, c, o);

            if ((o.att || (o.kl && o.vl)) && (Date.now() - a) / 60000 < c) { // 从本地缓存取数据

                if (o.f == 'vd') { // view data
                    if (o.ctn) {
                        that.vc('<i id="' + o.ctn + '"></i>');
                    }
                    that.vd(o);
                } else {
                    that.ld(o);
                }

            } else { // 从服务器取新数据

                o = that.obj(cmd);
                d = o.tb || '';
                if (o.f == 'vd') { // view data
                    if (o.ctn) {
                        that.vc('<i id="' + o.ctn + '"></i>');
                        ctn = that.gn(o.ctn);
                    } else {
                        ctn = that.gn('fwCtt');
                        that.sn('FW', 'n_');
                    }
                } else { // list data
                    if (o.ctn) {
                        ctn = that.gn(o.ctn);
                        if (!ctn) {
                            that.gv.lb.innerHTML = '<i id="' + o.ctn + '"></i>';
                            ctn = that.gn(o.ctn);
                        }
                    } else {
                        ctn = that.gn((d || '') + 'LB') || that.gv.lb;
                    }
                }
                that.loading(ctn);
                that.req(cmd + '`back`sd');
            }
        });
    },

    // save data
    sd: function(A) {
        var a, b, c, d, s;
        A = this.obj(A);
        if (!A.key) A.key = 'f`' + (A.f || '') + '`tb`' + (A.tb || '') + '`kw`' + (A.kw || '') + '`od`' + (A.od || '') + '`pn`' + (A.pn || '') + '`pr`' + (A.pr || '') + '`ctn`' + (A.ctn || '') + '`tpl`' + (A.tpl || '');
        if (!A.tm) A.tm = Date.now();
        s = this.e36(JSON.stringify(A));
        this.idb(this.md5(this.ini.prefix + A.key), function(val) {}, s);
        if (A.f == 'vd') this.vd(A);
        else this.ld(A);
    },

    // list data
    ld: function(A) {
        var a, b, c, d, e, f, i, l, n, o, s, t, v, x, y, z, ctn, nl, pn, pr;
        A = this.obj(A);
        pn = A.pn || 1;
        pr = A.pr || 40;
        a = this.tpl[A.tpl || A.tb];
        if (!a) return this.msg('列表模板未定义！');
        if (A.ctn) {
            ctn = this.gn(A.ctn);
            if (!ctn) return this.msg('容器未定义！');
        } else {
            ctn = this.gn((A.tb || '') + 'LB') || this.gv.lb;
        }
        ctn.innerHTML = '';
        if (A.kl && A.vl) {
            A.dl = [];
            b = (A.vl || '').split('~');
            c = (A.kl || '').split('`');
            d = (A.nl || '').split('`');
            nl = {};
            for (z = 0; z < c.length; z++) {
                nl[c[z]] = d[z] || '';
            }
            for (z = 0; z < b.length; z++) {
                e = (b[z] || '').split('`');
                o = {};
                for (y = 0; y < e.length; y++) {
                    f = c[y] || '';
                    if (!f) continue;
                    o[f] = e[y];
                }
                A.dl[z] = o;
            }
        }

        if (A.dl) {
            b = A.dl;
            f = [];
            i = 0;
            i += (pn - 1) * pr;
            for (z = 0; z < b.length; z++) {
                i++;
                o = b[z];
                s = a;
                for (y in o) {
                    if (typeof o[y] != 'string' && typeof o[y] != 'number') continue;
                    else v = o[y];
                    v = '' + this.sc(v);
                    if (y == 'des') v = v.replace(/\<br *\/\>/g, '');
                    s = s.replace(new RegExp('{{' + y + '}}', 'g'), v);
                    if (s.indexOf('{{QR_' + y + '}}') != -1) {
                        s = s.replace(new RegExp('{{QR_' + y + '}}', 'g'), this.qrl(v, o.user_un, o.user_ava, o.user_qr));
                    }
                    if (s.indexOf('{{NF_' + y + '}}') != -1) {
                        s = s.replace(new RegExp('{{NF_' + y + '}}', 'g'), this.nfmt(v));
                    }
                    if (s.indexOf('{{MF_' + y + '}}') != -1) {
                        s = s.replace(new RegExp('{{MF_' + y + '}}', 'g'), this.mnfmt(v, 2));
                    }
                    if (s.indexOf('{{TS_' + y + '}}') != -1) {
                        s = s.replace(new RegExp('{{TS_' + y + '}}', 'g'), this.tf(v, 'y-m-d'));
                    }
                    if (s.indexOf('{{GPD_' + y + '}}') != -1) {
                        s = s.replace(new RegExp('{{GPD_' + y + '}}', 'g'), this.gpd(this.ud.ac, v));
                    }
                    if (s.indexOf('{{SS_' + y + '}}') != -1) {
                        s = s.replace(new RegExp('{{SS_' + y + '}}', 'g'), v == 1 ? ' s4_' : '');
                    }
                    if (s.indexOf('{{HI_' + y + '}}') != -1) {
                        s = s.replace(new RegExp('{{HI_' + y + '}}', 'g'), v == '' ? ' h_' : '');
                    }
                    if (s.indexOf('{{LIST_' + y + '}}') != -1) {
                        s = s.replace(new RegExp('{{LIST_' + y + '}}', 'g'), v ? v : '');
                    }
                    if (s.indexOf('{{ATT_' + y + '}}') != -1) {
                        s = s.replace(new RegExp('{{ATT_' + y + '}}', 'g'), v == 1 ? '2' : '1');
                    }
                    if (s.indexOf('{{FAV_' + y + '}}') != -1) {
                        s = s.replace(new RegExp('{{FAV_' + y + '}}', 'g'), v == 1 ? '5' : '4');
                    }
                    if (s.indexOf('{{PY_' + y + '}}') != -1) {
                        s = s.replace(new RegExp('{{PY_' + y + '}}', 'g'), (o['sect'] || o['sect'] == 0) ? '门派' : '用户');
                    }
                    if (s.indexOf('{{PN_' + y + '}}') != -1) {
                        s = s.replace(new RegExp('{{PN_' + y + '}}', 'g'), parseInt(v) || 0);
                    }
                    if (s.indexOf('{{S1_' + y + '}}') != -1) {
                        s = s.replace(new RegExp('{{S1_' + y + '}}', 'g'), v.substr(1));
                    }
                    if (s.indexOf('{{NL_' + y + '}}') != -1) {
                        s = s.replace(new RegExp('{{NL_' + y + '}}', 'g'), nl[y] || y);
                    }
                    if (s.indexOf('{{lnum}}') != -1) {
                        s = s.replace(/{{lnum}}/g, i);
                    }
                    if (s.indexOf('{{enum}}') != -1) {
                        s = s.replace(/{{enum}}/g, z % 2 ? 1 : 2); // even number
                    }
                    if (s.indexOf('{{bgc}}') != -1) {
                        s = s.replace(/{{bgc}}/g, this.rbgc());
                    }
                }

                s = s.replace(/{{[a-zA-Z0-9_]+}}/g, '');
                //console.log(s);
                this.gv.tmp.innerHTML = '';
                n = this.gv.tmp.appendChild(document.createElement('i'));
                n.innerHTML = s;
                ctn.appendChild(n.firstChild);
            }

        } else if (A.att) {

            o = A.att;
            nl = A.nl || {};
            s = a;
            for (z in o) {
                if (typeof o[z] != 'string' && typeof o[z] != 'number') continue;
                else v = o[z];
                v = '' + this.sc(v);
                if (z == 'des') v = v.replace(/\<br *\/\>/g, '');

                if (s.indexOf(' tp="list"') != -1) {
                    s = a;
                }
                s = s.replace(new RegExp('{{' + z + '}}', 'g'), v);
                if (s.indexOf('{{attKey}}') != -1) {
                    s = s.replace(new RegExp('{{attKey}}', 'g'), z);
                }
                if (s.indexOf('{{attName}}') != -1) {
                    s = s.replace(new RegExp('{{attName}}', 'g'), nl[z] || z);
                }
                if (s.indexOf('{{attVal}}') != -1) {
                    s = s.replace(new RegExp('{{attVal}}', 'g'), v);
                }

                if (s.indexOf('{{QR_' + z + '}}') != -1) {
                    s = s.replace(new RegExp('{{QR_' + z + '}}', 'g'), this.qrl(v, o.user_un, o.user_ava, o.user_qr));
                }
                if (s.indexOf('{{NF_' + z + '}}') != -1) {
                    s = s.replace(new RegExp('{{NF_' + z + '}}', 'g'), this.nfmt(v));
                }
                if (s.indexOf('{{MF_' + z + '}}') != -1) {
                    s = s.replace(new RegExp('{{MF_' + z + '}}', 'g'), this.mnfmt(v, 2));
                }
                if (s.indexOf('{{TS_' + z + '}}') != -1) {
                    s = s.replace(new RegExp('{{TS_' + z + '}}', 'g'), this.tf(v, 'y-m-d'));
                }
                if (s.indexOf('{{GPD_' + z + '}}') != -1) {
                    s = s.replace(new RegExp('{{GPD_' + z + '}}', 'g'), this.gpd(this.ud.ac, v));
                }
                if (s.indexOf('{{SS_' + z + '}}') != -1) {
                    s = s.replace(new RegExp('{{SS_' + z + '}}', 'g'), v == 1 ? ' s4_' : '');
                }
                if (s.indexOf('{{HI_' + z + '}}') != -1) {
                    s = s.replace(new RegExp('{{HI_' + z + '}}', 'g'), v == '' ? ' h_' : '');
                }
                if (s.indexOf('{{LIST_' + z + '}}') != -1) {
                    s = s.replace(new RegExp('{{LIST_' + z + '}}', 'g'), v ? v : '');
                }
                if (s.indexOf('{{ATT_' + z + '}}') != -1) {
                    s = s.replace(new RegExp('{{ATT_' + z + '}}', 'g'), v == 1 ? '2' : '1');
                }
                if (s.indexOf('{{FAV_' + z + '}}') != -1) {
                    s = s.replace(new RegExp('{{FAV_' + z + '}}', 'g'), v == 1 ? '5' : '4');
                }
                if (s.indexOf('{{PY_' + z + '}}') != -1) {
                    s = s.replace(new RegExp('{{PY_' + z + '}}', 'g'), (o['sect'] || o['sect'] == 0) ? '门派' : '用户');
                }
                if (s.indexOf('{{PN_' + z + '}}') != -1) {
                    s = s.replace(new RegExp('{{PN_' + z + '}}', 'g'), parseInt(v) || 0);
                }
                if (s.indexOf('{{S1_' + z + '}}') != -1) {
                    s = s.replace(new RegExp('{{S1_' + z + '}}', 'g'), v.substr(1));
                }
                if (s.indexOf('{{NL_' + z + '}}') != -1) {
                    s = s.replace(new RegExp('{{NL_' + z + '}}', 'g'), nl[z] || z);
                }
                if (s.indexOf('{{bgc}}') != -1) {
                    s = s.replace(/{{bgc}}/g, this.rbgc());
                }

                if (s.indexOf(' tp="list"') != -1) {
                    s = s.replace(/{{[a-zA-Z0-9_]+}}/g, '');
                    this.gv.tmp.innerHTML = '';
                    n = this.gv.tmp.appendChild(document.createElement('i'));
                    n.innerHTML = s;
                    ctn.appendChild(n.firstChild);
                }
            }

            if (s.indexOf(' tp="list"') < 0) {
                s = s.replace(/{{[a-zA-Z0-9_]+}}/g, '');
                ctn.innerHTML = s;
            }

        } else {
            ctn.innerHTML = '<i class="msg">查无数据！</i>';
            return this.msg('查无数据！');
        }
    },

    // view data
    vd: function(A) {
        var a, b, c, d, n, o, s, t, v, z, ctn, nl;
        o = this.obj(A);
        if (o.ctn) {
            ctn = this.gn(o.ctn);
            if (!ctn) return this.msg('容器未定义！');
        } else {
            ctn = this.gn('fwCtt');
        }
        s = this.tpl[o.tpl || o.tb];
        if (!s) return this.msg('内容模板未定义！');
        nl = o.nl || {};
        o = o.att;
        for (z in o) {
            if (typeof o[z] != 'string' && typeof o[z] != 'number') continue;
            else v = o[z];
            v = '' + this.sc(v);
            if (z == 'des') v = v.replace(/\<br *\/\>/g, '');

            if (s.indexOf(' tp="list"') != -1) {
                s = this.tpl[o.tpl || o.tb];
            }
            s = s.replace(new RegExp('{{' + z + '}}', 'g'), v);
            if (s.indexOf('{{attKey}}') != -1) {
                s = s.replace(new RegExp('{{attKey}}', 'g'), z);
            }
            if (s.indexOf('{{attName}}') != -1) {
                s = s.replace(new RegExp('{{attName}}', 'g'), nl[z] || z);
            }
            if (s.indexOf('{{attVal}}') != -1) {
                s = s.replace(new RegExp('{{attVal}}', 'g'), v);
            }

            if (s.indexOf('{{QR_' + z + '}}') != -1) {
                s = s.replace(new RegExp('{{QR_' + z + '}}', 'g'), this.qrl(v, o.user_un, o.user_ava, o.user_qr));
            }
            if (s.indexOf('{{NF_' + z + '}}') != -1) {
                s = s.replace(new RegExp('{{NF_' + z + '}}', 'g'), this.nfmt(v));
            }
            if (s.indexOf('{{MF_' + z + '}}') != -1) {
                s = s.replace(new RegExp('{{MF_' + z + '}}', 'g'), this.mnfmt(v, 2));
            }
            if (s.indexOf('{{TS_' + z + '}}') != -1) {
                s = s.replace(new RegExp('{{TS_' + z + '}}', 'g'), this.tf(v, 'y-m-d'));
            }
            if (s.indexOf('{{GPD_' + z + '}}') != -1) {
                s = s.replace(new RegExp('{{GPD_' + z + '}}', 'g'), this.gpd(this.ud.ac, v));
            }
            if (s.indexOf('{{SS_' + z + '}}') != -1) {
                s = s.replace(new RegExp('{{SS_' + z + '}}', 'g'), v == 1 ? ' s4_' : '');
            }
            if (s.indexOf('{{HI_' + z + '}}') != -1) {
                s = s.replace(new RegExp('{{HI_' + z + '}}', 'g'), v == '' ? ' h_' : '');
            }
            if (s.indexOf('{{LIST_' + z + '}}') != -1) {
                s = s.replace(new RegExp('{{LIST_' + z + '}}', 'g'), v ? v : '');
            }
            if (s.indexOf('{{ATT_' + z + '}}') != -1) {
                s = s.replace(new RegExp('{{ATT_' + z + '}}', 'g'), v == 1 ? '2' : '1');
            }
            if (s.indexOf('{{FAV_' + z + '}}') != -1) {
                s = s.replace(new RegExp('{{FAV_' + z + '}}', 'g'), v == 1 ? '5' : '4');
            }
            if (s.indexOf('{{PY_' + z + '}}') != -1) {
                s = s.replace(new RegExp('{{PY_' + z + '}}', 'g'), (o['sect'] || o['sect'] == 0) ? '门派' : '用户');
            }
            if (s.indexOf('{{PN_' + z + '}}') != -1) {
                s = s.replace(new RegExp('{{PN_' + z + '}}', 'g'), parseInt(v) || 0);
            }
            if (s.indexOf('{{S1_' + z + '}}') != -1) {
                s = s.replace(new RegExp('{{S1_' + z + '}}', 'g'), v.substr(1));
            }
            if (s.indexOf('{{NL_' + z + '}}') != -1) {
                s = s.replace(new RegExp('{{NL_' + z + '}}', 'g'), nl[z] || z);
            }
            if (s.indexOf('{{LK_' + z + '}}') != -1) {
                s = s.replace(new RegExp('{{LK_' + z + '}}', 'g'), this.lkfmt(v));
            }
            if (s.indexOf('{{bgc}}') != -1) {
                s = s.replace(/{{bgc}}/g, this.rbgc());
            }

            if (s.indexOf(' tp="list"') != -1) {
                s = s.replace(/{{[a-zA-Z0-9_]+}}/g, '');
                this.gv.tmp.innerHTML = '';
                n = this.gv.tmp.appendChild(document.createElement('i'));
                n.innerHTML = s;
                ctn.appendChild(n.firstChild);
            }
        }

        if (s.indexOf(' tp="list"') < 0) {
            s = s.replace(/{{[a-zA-Z0-9_]+}}/g, '');
            ctn.innerHTML = s;
        }
    },

    // view content
    vc: function(A, B, C) {
        var a, b, c, d;
        B = B || '';
        C = C || 'n_';
        a = this.gn('fwCtt');
        b = this.gn('fwCtn');
        if (A) a.innerHTML = A;
        if (B) b.className = B;
        this.sn('FW', C);
    },

    // safe code
    sc: function(A) {
        var a, b, c, d, e, f, k, l, p, s, x, y, z;
        a = A;
        x = typeof a;
        if (x == 'object' || x == 'boolean' || x == 'function' || x == 'undefined') return '';
        else if (x == 'number') return A;
        a = this.e36(a, 2);
        a = a.replace(/\</g, '&lt;');
        a = a.replace(/\>/g, '&gt;');
        a = a.replace(/\'/g, '&#39;');
        a = a.replace(/\"/g, '&quot;');
        a = a.replace(/\r\n/g, '<br/>');
        a = a.replace(/\r/g, '<br/>');
        a = a.replace(/\n/g, '<br/>');

        f = ['E', 'U', 'P', 'A', 'V', 'F'];
        for (z = 0; z < f.length; z++) {
            k = f[z] + '.';
            a = a.split(k);
            b = a.length;
            c = [];
            c.push(a[0] || '');
            for (y = 1; y < b; y++) {
                p = a[y].indexOf(' ');
                if (p > 0) {
                    d = a[y].substr(0, p);
                    e = a[y].substr(p + 1);
                    l = d.length;
                    if ((!isNaN(d) || z < 2) && (l > 0 && l < 16)) s = this.pfile(d, f[z]) + e;
                    else if (f[z] == 'U') s = this.pfile(d, f[z]) + e;
                    else s = k + a[y];
                } else s = k + a[y];
                c.push(s);
            }
            a = c.join('');
        }

        a = a.split('@');
        b = a.length;
        c = [];
        c.push(a[0] || '');
        for (y = 1; y < b; y++) {
            p = a[y].indexOf(' ');
            if (p > 0) {
                d = a[y].substr(0, p);
                e = a[y].substr(p + 1);
                l = d.length;
                if (l > 0 && l < 16 && d.toLowerCase().match(/[a-z0-9]+/)) s = '<i class="tag" onclick="ryo.gd(\'f`vd`tb`user`kw`uni.' + d + '\'); ryo.se()" title="查看TA的空间>@' + d + '</i>' + e;
                else s = '@' + a[y];
            } else s = '@' + a[y];
            c.push(s);
        }
        a = c.join('');

        a = a.split('#');
        b = a.length;
        c = [];
        c.push(a[0] || '');
        for (y = 1; y < b; y++) {
            p = a[y].indexOf(' ');
            if (p > 0) {
                d = a[y].substr(0, p);
                e = a[y].substr(p + 1);
                l = d.length;
                if (l > 0 && l < 26) s = '<i class="tag" onclick="ryo.gd(\'f`ld`tb`dyna`kw`tag.' + d + '\'); ryo.se()" title="检索此标签的动态">#' + d + '</i>' + e;
                else s = '#' + a[y];
            } else s = '#' + a[y];
            c.push(s);
        }
        a = c.join('');

        a = a.replace(/\t/g, '&nbsp;');
        a = a.replace(/\v/g, '&nbsp;');
        a = a.replace(/S\./g, '&nbsp;');
        a = a.replace(/N\./g, '\n');
        a = a.replace(/D\./g, '.');
        a = a.replace(/Q\./g, '&quot;');
        a = a.replace(/W\./g, '&#39;');
        return a;
    },

    // text editor tpl
    tet: function(A, B) {
        var a, b, c, d, e, f, g, h, i, s, t, z;
        s = '';
        this.sn('EB', 'n_');
        a = this.gv.cmd;
        a.focus();
        b = a.value || '';
        c = a.selectionStart;
        d = a.selectionEnd;
        e = b.substr(0, c) || '';
        f = b.substr(d) || '';
        g = '';
        s = e.slice(-2) || '';
        s = s.replace('？', '?');
        if (A) s = A;
        s = s.toLowerCase();

        switch (s) {
            case '?e':
                if (B) g = 'E.' + B + ' ';
                else g = 'E.expName ';
                break;
            case '?u':
                g = 'U.url,name,msg ';
                break;
            case '?p':
                if (B) g = 'P.' + B + ' ';
                else g = 'P.pid ';
                break;
            case '?a':
                if (B) g = 'A.' + B + ' ';
                else g = 'A.aid ';
                break;
            case '?v':
                if (B) g = 'V.' + B + ' ';
                else g = 'V.vid ';
                break;
            case '?f':
                if (B) g = 'F.' + B + ' ';
                else g = 'F.fid ';
                break;
        }

        if (!A) {
            c -= 2;
        }
        if (c < 0) c = 0;
        if (g) e = b.substr(0, c);
        h = c + g.length;
        b = e + g + f;
        i = a.scrollTop;
        a.value = b;
        a.scrollTop = i;
        a.setSelectionRange(h, h);
    },

    // dynamic picture
    tpic: function(A) {
        var a, b, c, d, l, n, s, z;
        if (!A) return '';
        A = A.split(',');
        l = A.length;
        n = 0;
        s = [];
        for (z = 0; z < l; z++) {
            a = (A[z] || '').trim();
            if (!a) continue;
            n++;
            b = '<i class="tppl tppl' + n + '"><img src="p' + a + '_p" onload="var a,b,c,d;a=this;b=a.width;c=a.height;d=WD.na(\'ld\')||0;if(c<b&&d!=1){WD.na(\'ld\',1);a.className=a.className+\' H\'};"/></i>';
            s.push(b);
        }
        if (s.length < 1) return '';
        c = 'tppb' + n;
        s = '<i class="tPvPicB ' + c + '" onclick="picView(this)">' + s.join('') + '<i class="cf"></i></i>';
        return s;
    },

    // qrcode list
    qrl: function(A, B, C, D) {
        var a, b, c, d, e, f, z;
        a = (A || '').split(/, */);
        b = [];
        for (z = 0; z < a.length; z++) {
            c = a[z] || '';
            if (!c) continue;
            d = c.split('/');
            e = d[d.length - 1];
            b.push('<i class="qrlistB"><img class="qrlistImg" src="img/sys/loading.gif" un="' + B + '" ava="' + C + '" qr="' + D + '" bgi="' + c + '" onload="ryo.nqr(this);" /><i class="ico30 ico30Save qrlistBtn" title="save|保存" onclick="ryo.npg(this.previousSibling.src, \'' + e + '\')"></i></i>');
        }
        b = b.join('');
        return b;
    },

    // number format
    nfmt: function(A) {
        var a;
        A = parseInt(A) || 0;
        if (!A) return 0;
        if (A > 100000000) {
            a = Math.ceil(A / 100000000 * 100) / 100;
            a = a + 'e';
        } else if (A > 10000000) {
            a = Math.ceil(A / 10000000 * 100) / 100;
            a = a + 'kw';
        } else if (A > 10000) {
            a = Math.ceil(A / 10000 * 100) / 100;
            a = a + 'w';
        } else a = A;
        return a;
    },

    // money format
    mnfmt: function(A, B, C) {
        var a, b;
        A = parseInt(A) || 0;
        B = (B == 0) ? B : B ? B : 2;
        if (B > 6) B = 6;
        if (B < 0) B = 0;
        a = C || this.ini.mnint || 10000;
        b = Math.pow(10, B);
        A = Math.ceil(A / a * b) / b;
        if (A == 0 && B > 0) {
            A = A + '.' + ('000000').substr(0, B);
        }
        return A;
    },

    // link format
    lkfmt: function(A) {
        var a, b, c, d, s, z;
        s = (A || '').trim();
        s = [];
        a = (A || '').trim().split('http');
        s.push(a[0]);
        for (z = 1; z < a.length; z++) {
            b = (a[z] || '').split('<br/>');
            c = b[0] || '';
            if (b.length > 1) {
                b.shift();
                d = b.join('<br/>');
                s.push('<a href="http' + c + '" target="_blank">http' + c + '</a><br/>' + d);
            } else {
                s.push('<a href="http' + c + '" target="_blank">http' + c + '</a>');
            }

        }
        s = s.join('');
        return s;
    },

    // get name for value
    vn: function(A, B) {
        var a, b, k, v, o, z;
        o = {};
        a = (A || '').split('-');
        for (z = 0; z < A.length; z += 2) {
            k = a[z];
            v = a[z + 1];
            o[k] = v;
        }
        return o[B];
    },

    // parse file
    pfile: function(A, B) {
        var a, b, c, d, e, f, g, h, i, l, n, s, z;
        A = A || '';
        B = B || 'P';
        if (!A) return '';
        if (B == 'E') {
            a = A.substr(0, 1);
            b = { 'd': 'dhg', 'h': 'htg', 'm': 'mtg' };
            c = '';
            if (isNaN(A)) {
                s = '<img class="sExp" src="img/exp/' + b[a] + '/' + A + '.png" />';
            } else {
                c = ' class="uExp" onclick="ryo.req(\'f`fav`tb`efav`id`' + A + '\')" title="收藏到表情库"';
                d = 'f' + A;
                s = '<img src="' + d + '"' + c + ' />';
            }

        } else if (B == 'U') {
            A = A.split(',');
            a = A[0] || '';
            b = A[1] ? A[1] : a ? a : '';
            c = A[2] ? A[2] : b ? b : '';
            e = a.substr(0, 1);
            f = a.substr(1) || 0;
            if (e == 't') s = '<i class="lk" onclick="ryo.cmd(\'ld t v.' + f + ' 1 1 t.2\'); ryo.se()">' + b + '</i>'; // view dynamic
            else if (a && b) s = '<a class="lk" href="' + a + '" target="_blank"' + c + ' onclick="se()">' + b + '</a>';
            else s = '';

        } else if (B == 'P') {
            d = 'p' + A;
            s = '<i class="picCtn"><img class="pic" src="' + d + '" onclick="ry.picView(this.parentNode.parentNode)" /></i>';

        } else if (B == 'A') {
            i = 'a' + rs(2) + A;
            s = '<i id="' + i + '" class="adoCtn"><img class="imgLoad" src="img/sys/load.png" onload="ryo.req(\'f`pview`ft`ado`id`' + A + '`ctn`' + i + '\')"/></i>';

        } else if (B == 'V') {
            i = 'v' + rs(2) + A;
            s = '<i id="' + i + '" class="vdoCtn"><img class="imgLoad" src="img/sys/load.png" onload="ryo.req(\'f`pview`ft`vdo`id`' + A + '`ctn`' + i + '\')"/></i>';

        } else if (B == 'F') {
            i = 'f' + rs(2) + A;
            s = '<i id="' + i + '" class="fileCtn"><img class="imgLoad" src="img/sys/load.png" onload="ryo.req(\'f`pview`ft`file`id`' + A + '`ctn`' + i + '\')"/></i>';

        }
        return s;
    },

    // picture view
    picView: function(A) {
        var a, b, c, d, e, f, n, o, s, z;
        A = this.gn(A);
        if (!A) return;
        a = A.getElementsByTagName('IMG');
        b = a.length;
        if (b < 1) return;
        c = this.gn('PV');
        if (!c) return;
        c.fc.firstChild.innerHTML = '';
        n = 0;
        for (z = 0; z < b; z++) {
            d = a[z] || '';
            if (!d) continue;
            e = d.className.indexOf('sExp');
            f = d.className.indexOf('uExp');
            g = d.className.indexOf('imgLoad');
            if (e != -1 || f != -1 || g != -1) continue;
            o = c.fc.firstChild.appendChild(document.createElement('img'));
            s = d.getAttribute('src');
            s = s.replace('_p', '');
            o.setAttribute('src', s);
            n++;
        }
        this.nt(c.fc.nextSibling.firstChild.nextSibling, '1/' + n);
        this.sn1(c.fc.firstChild.firstChild);
        this.sn(c);
    },

    // picture navigation
    picNav: function(A) {
        var a, b, c, d, e, f, g, n, o, z;
        A = A || 1;
        o = this.gn('PV');
        n = this.gn('picNum');
        if (!o || !n) return;
        a = o.fc.firstChild.getElementsByTagName('IMG');
        b = a.length;
        if (b < 1) return;
        for (z = 0; z < b; z++) {
            c = a[z].className || '';
            if (c.indexOf('h_') == -1) {
                d = z;
                break;
            }
        }
        d = d || 0;
        e = d - 1;
        f = d + 1;
        if (e < 0) e = b - 1;
        if (f >= b) f = 0;
        if (A == 1) {
            g = (e + 1) + '/' + b;
            this.sn1(a[e]);
            n.innerHTML = g;
        } else {
            g = (f + 1) + '/' + b;
            this.sn1(a[f]);
            n.innerHTML = g;
        }
    },

    // picture scale
    picSca: function(A) {
        var a, b, c, d, e, f, g, n, o, z;
        A = A || 1;
        o = this.gn('PV');
        if (!o) return;
        a = o.fc.firstChild.getElementsByTagName('IMG');
        b = a.length;
        if (b < 1) return;
        for (z = 0; z < b; z++) {
            c = a[z].className || '';
            if (c.indexOf('h_') == -1) {
                d = z;
                break;
            }
        }
        d = d || 0;
        e = a[d];
        if (!e) return;
        f = e.offsetWidth;
        if (A == 2) f += f * .2;
        else {
            f -= f * .2;
            if (f < 20) f = 20;
        }
        css(e, 'w', f + 'px');
    },

    // picture rotation
    picRot: function(A) {
        var a, b, c, d, e, f, g, h, n, o, p, s, w, z;
        A = A || 1;
        o = this.gn('PV');
        if (!o) return;
        a = o.fc.firstChild.getElementsByTagName('IMG');
        b = a.length;
        if (b < 1) return;
        for (z = 0; z < b; z++) {
            c = a[z].className || '';
            if (c.indexOf('h_') == -1) {
                d = z;
                break;
            }
        }
        d = d || 0;
        n = a[d];
        if (!n) return;

        a = n.naturalWidth / n.naturalHeight;
        o = document.createElement('canvas');
        p = o.getContext('2d');
        w = o.width = n.naturalWidth;
        h = o.height = w / a;

        if (A == 1) s = 6;
        else s = 8;
        this.rimg(o, p, w, h, s); // 改变图片方向
        p.drawImage(n, 0, 0, w, h);
        b = o.toDataURL('image/jpeg', 1);
        this.na(n, 'src', b);
        o = null;
        p = null;
        b = '';
    },

    // show language
    slg: function(A) {
        var a, b, c, d, l, z;
        l = this.ud.lg || 'cn';
        a = [];
        if (!LANG[l]['lg']) return msg('err language');
        for (z in LANG[l]['lg']) {
            a.push('<i class="lbg l_' + z + '" onclick="ryo.setlg(\'' + z + '\')"><i class="ltxt">' + z + '</i></i>');
        }
        a = '<i class="lang">' + a.join('') + '<i class="cf"></i></i>';
        this.gv.LB.innerHTML = a;
        this.gv.CTN.scrollTop = 0;
    },

    // set language
    setlg: function(A) {
        A = A || 'cn';
        this.ls('LANG', A);
        this.req('f`lg`' + A);
        location.reload();
    },

    // map api
    map: function(A) {
        var a, b, c, d, o, u, that = this;
        this.gv.mapZ = this.gv.mapZ || 12; // map zoom
        A = A || 'bd';

        if (A == 'bd' || A == 'bdgl') { // 百度地图
            this.gv.mapapi = 'bd';
            a = this.ini.map_bd_js || '';

            if (A == 'bd') {
                window.HOST_TYPE = '2';
                window.BMap_loadScriptTime = new Date().getTime();
                u = 'https://api.map.baidu.com/getscript?v=2.0&ak=' + a;
            } else {
                window.BMAP_PROTOCOL = "https";
                window.BMapGL_loadScriptTime = new Date().getTime();
                this.ac('map_baidu', 'https://api.map.baidu.com/res/webgl/10/bmap.css', 2);
                u = 'https://api.map.baidu.com/getscript?type=webgl&v=1.0&ak=' + a;
            }

            this.aj('map_baidu', u, 2, function() {
                if (A == 'bdgl') BMap = BMapGL;
                that.gv.map = new BMap.Map('MAP');
                that.gv.map.centerAndZoom(new BMap.Point(that.ud.gps.lon, that.ud.gps.lat), that.gv.mapZ);
                that.gv.map.enableScrollWheelZoom();
                that.gv.mapCtr = new BMap.NavigationControl({ anchor: BMAP_ANCHOR_BOTTOM_LEFT, type: BMAP_NAVIGATION_CONTROL_LARGE, showZoomInfo: true });
                that.gv.map.addControl(that.gv.mapCtr);
                that.gv.mapTyp = new BMap.MapTypeControl({ anchor: BMAP_ANCHOR_TOP_LEFT });
                that.gv.map.addControl(that.gv.mapTyp);
                that.gv.mapGeoC = new BMap.GeolocationControl({ anchor: BMAP_ANCHOR_BOTTOM_RIGHT });
                that.gv.map.addControl(that.gv.mapGeoC);
                that.gv.mapSca = new BMap.ScaleControl({ anchor: BMAP_ANCHOR_BOTTOM_RIGHT });
                that.gv.map.addControl(that.gv.mapSca);
                that.gv.mapGeo = new BMap.Geolocation();
                that.gv.mapCode = new BMap.Geocoder();
                that.gv.mapCity = new BMap.LocalCity();

                c = '<i class="btn btnCtr" onclick="ryo.shCtr(\'mapCtr\');ryo.se()"></i><i class="btn btnSca" onclick="ryo.shCtr(\'mapSca\');ryo.se()"></i><i class="btn btnTyp" onclick="ryo.shCtr(\'mapTyp\');ryo.se()"></i><i class="btn btnEye" onclick="ryo.shCtr(\'mapEye\');ryo.se()"></i>';
                that.gn('mapBtnB').innerHTML += c;

                that.gv.mapGeo.getCurrentPosition(function(res) {
                    if (this.getStatus() == BMAP_STATUS_SUCCESS) {
                        console.log('GEO定位成功');
                        console.log(res);
                        //that.msg(JSON.stringify(res));
                        b = res.address;
                        o = {};
                        o.lon = res.point.lng || 0;
                        o.lat = res.point.lat || 0;
                        o.ccod = b.countryCode || 0;
                        o.code = b.adcode || 0;
                        o.prov = b.province || '';
                        o.city = b.city || '';
                        o.area = b.district || '';
                        o.town = b.town || '';
                        o.stre = b.street || '';
                        o.numb = b.street_number || '';
                        o.type = 'html5';
                        that.mapG(o);
                    } else {
                        console.log('GEO定位失败');
                        that.gv.mapCity.get((res) => {
                            console.log('IP定位成功');
                            console.log(res);
                            o = {};
                            o.lon = res.center.lng || 0;
                            o.lat = res.center.lat || 0;
                            o.ccod = res.countryCode || 0;
                            o.code = res.adcode || 0;
                            o.prov = res.province || '';
                            o.city = res.name || '';
                            o.area = res.district || '';
                            o.town = res.town || '';
                            o.stre = res.street || '';
                            o.numb = res.streetNumber || '';
                            o.type = 'ip';
                            that.mapG(o);
                        });
                    }
                }, {
                    enableHighAccuracy: true,
                    timeout: 10000,
                    maximumAge: 0,
                    SDKLocation: true
                });

                that.gv.mapGeoC.addEventListener('locationSuccess', (e) => {
                    console.log('定位成功');
                    console.log(e);
                    b = e.addressComponent;
                    o = {};
                    o.lon = e.point.lng || 0;
                    o.lat = e.point.lat || 0;
                    o.ccod = b.countryCode || 0;
                    o.code = b.adcode || 0;
                    o.prov = b.province || '';
                    o.city = b.city || '';
                    o.area = b.district || '';
                    o.town = b.town || '';
                    o.stre = b.street || '';
                    o.numb = b.streetNumber || '';
                    o.type = 'ip';
                    that.mapG(o);
                });
                that.gv.mapGeoC.addEventListener('locationError', (e) => {
                    console.log('定位失败');
                });

                that.gv.map.addEventListener('click', (e) => {
                    c = e.point.lng || 0;
                    d = e.point.lat || 0;
                    that.msg('经纬坐标(秒)：' + that.d2s(c) + ',' + that.d2s(d));
                    that.msg('经纬坐标(度)：' + c + ',' + d);
                    that.mapM([
                        [c, d, 'map4', '新位置', 0, 'newPosMarker']
                    ]);
                });
            });

        } else if (A == 'gd') { // 高德地图
            this.gv.mapapi = 'gd';
            a = this.ini.map_gd_js || '';
            b = this.ini.map_gd_js2 || '';
            window._AMapSecurityConfig = {
                    securityJsCode: b
                }
                // 2.0, 2.1Beta
            this.aj('map_ad', 'https://webapi.amap.com/maps?v=2.0&key=' + a, 2, function() {
                that.gv.map = new AMap.Map('MAP', {
                    zoom: that.gv.mapZ,
                    center: [that.ud.gps.lon, that.ud.gps.lat],
                    viewMode: '3D'
                });

                c = '<i class="btn btnCtr" onclick="ryo.shCtr(\'mapCtr\');ryo.se()"></i><i class="btn btnBar" onclick="ryo.shCtr(\'mapBar\');ryo.se()"></i><i class="btn btnSca" onclick="ryo.shCtr(\'mapSca\');ryo.se()"></i><i class="btn btnEye" onclick="ryo.shCtr(\'mapEye\');ryo.se()"></i>';
                that.gn('mapBtnB').innerHTML += c;

                that.gv.map.on('click', (e) => {
                    c = e.lnglat.lng || 0;
                    d = e.lnglat.lat || 0;
                    that.msg('经纬坐标(秒)：' + that.d2s(c) + ',' + that.d2s(d));
                    that.msg('经纬坐标(度)：' + c + ',' + d);
                    that.mapM([
                        [c, d, 'map4', '新位置', 0, 'newPosMarker']
                    ]);
                });

                that.gv.map.plugin(['AMap.ControlBar', 'AMap.ToolBar', 'AMap.Scale', 'AMap.HawkEye', 'AMap.Geolocation', 'AMap.Geocoder', 'AMap.CitySearch', 'AMap.AutoComplete', 'AMap.PlaceSearch'], function() {
                    that.gv.mapCtr = new AMap.ControlBar({
                        visible: true,
                        position: { right: '10px', top: '30px' },
                        showControlButton: true // 是否显示倾斜、旋转按钮。默认为 true
                    });

                    that.gv.mapBar = new AMap.ToolBar({
                        visible: true,
                        position: { right: '40px', top: '120px' }
                    });

                    that.gv.mapSca = new AMap.Scale({
                        visible: true,
                        position: { right: '10px', bottom: '10px' }
                    });

                    that.gv.mapEye = new AMap.HawkEye({
                        visible: true,
                        position: { left: '0px', bottom: '0px' }
                    });

                    that.gv.mapGeo = new AMap.Geolocation({
                        visible: true,
                        position: { left: '20px', bottom: '20px' },
                        enableHighAccuracy: true, // 是否使用高精度定位，默认:true
                        timeout: 10000, // 超时毫秒数，默认：无穷大
                        noIpLocate: 0, // 是否禁止使用IP定位，可选值0-3
                        noGeoLocation: 0, // 是否禁止使用浏览器Geolocation定位，可选值0-3
                        GeoLocationFirst: true, // 是否优先使用浏览器定位，失败后使用IP定位
                        maximumAge: 0, // 定位结果缓存0毫秒，默认：0
                        convert: true, // 是否使用坐标偏移，偏移后的坐标为高德坐标，默认：true
                        showButton: false, // 显示定位按钮，默认：true
                        buttonPosition: 'LB', // 定位按钮停靠位置，默认：'LB'，左下角
                        buttonOffset: new AMap.Pixel(0, 0), // 定位按钮与设置的停靠位置的偏移量，默认：Pixel(10, 20)
                        showMarker: true, // 定位成功后在定位到的位置显示点标记，默认：true
                        //markerOptions: {}, // 定位点Marker的配置，不设置该属性则使用默认Marker样式
                        showCircle: true, // 定位成功后用圆圈表示定位精度范围，默认：true
                        //circleOptions: {}, // 定位点Circle的配置，不设置该属性则使用默认Circle样式
                        panToLocation: true, // 定位成功后将定位到的位置作为地图中心点，默认：true
                        zoomToAccuracy: true, // 定位成功后调整地图视野范围使定位位置及精度范围视野内可见，默认：false
                        useNative: false, // 是否使用安卓定位sdk用来进行定位
                        extensions: 'base' // 是否需要周边POI、道路交叉口等信息，可选值'base'、'all'。
                    });

                    that.gv.mapCode = new AMap.Geocoder();
                    that.gv.mapCity = new AMap.CitySearch();
                    that.gv.mapAut = new AMap.AutoComplete({
                        city: A,
                        datatype: 'poi',
                        citylimit: true,
                        input: '',
                        output: ''
                    });

                    that.gv.mapPla = new AMap.PlaceSearch({
                        city: that.ud.gps.city || '',
                        type: '',
                        pageSize: 10,
                        pageIndex: 1,
                        extensions: 'base'
                    });

                    that.gv.map.addControl(that.gv.mapCtr);
                    that.gv.map.addControl(that.gv.mapBar);
                    that.gv.map.addControl(that.gv.mapSca);
                    that.gv.map.addControl(that.gv.mapEye);
                    that.gv.map.addControl(that.gv.mapGeo);
                    //that.gv.map.addControl(that.gv.mapCity);
                    //that.gv.map.addControl(that.gv.mapAut);
                    //that.gv.map.addControl(that.gv.mapPla);

                    that.gv.mapGeo.getCurrentPosition((sta, res) => { // 获取用户当前的精确位置信息
                        if (sta == 'complete') {
                            console.log('GEO定位成功');
                            console.log(res);
                            o = {};
                            c = res.position;
                            o.lon = c[0] || 0;
                            o.lat = c[1] || 0;
                            o.ccod = res.countryCode || 0;
                            o.code = res.adcode || 0;
                            o.prov = res.province || '';
                            o.city = res.city || '';
                            o.area = res.district || '';
                            o.town = res.town || '';
                            o.stre = res.street || '';
                            o.numb = res.streetNumber || '';
                            o.type = res.location_type || '';
                            that.mapG(o);
                        } else if (sta == 'error') {
                            console.log('GEO定位失败');
                            //console.log(res);
                            that.gv.mapGeo.getCityInfo((sta, res) => { // 进行IP城市查询
                                if (sta == 'complete') {
                                    console.log('城市IP定位成功');
                                    console.log(res);
                                    o = {};
                                    c = res.position;
                                    o.lon = c[0] || 0;
                                    o.lat = c[1] || 0;
                                    o.ccod = res.countryCode || 0;
                                    o.code = res.adcode || 0;
                                    o.prov = res.province || '';
                                    o.city = res.city || '';
                                    o.area = res.district || '';
                                    o.town = res.town || '';
                                    o.stre = res.street || '';
                                    o.numb = res.streetNumber || '';
                                    o.type = res.location_type || '';
                                    that.mapG(o);
                                } else if (sta == 'error') {
                                    console.log('城市IP定位失败');
                                    //console.log(res);
                                    that.gv.mapCity.getLocalCity((sta, res) => {
                                        if (sta == 'complete') {
                                            console.log('城市查询成功');
                                            console.log(res);
                                            o = {};
                                            c = res.rectangle.split(',');
                                            o.lon = c[0] || 0;
                                            o.lat = c[1] || 0;
                                            o.ccod = res.countryCode || 0;
                                            o.code = res.adcode || 0;
                                            o.prov = res.province || '';
                                            o.city = res.city || '';
                                            o.area = res.district || '';
                                            o.town = res.town || '';
                                            o.stre = res.street || '';
                                            o.numb = res.streetNumber || '';
                                            o.type = 'ip';
                                            that.mapG(o);
                                        } else if (sta == 'error') {
                                            console.log('城市查询失败');
                                            //console.log(res);
                                            that.gv.mapCity.getCityByIp(that.ud.cip || '', (sta, res) => {
                                                if (sta == 'complete') {
                                                    console.log('用户IP定位成功');
                                                    console.log(res);
                                                    o = {};
                                                    c = res.rectangle.split(',');
                                                    o.lon = c[0] || 0;
                                                    o.lat = c[1] || 0;
                                                    o.ccod = res.countryCode || 0;
                                                    o.code = res.adcode || 0;
                                                    o.prov = res.province || '';
                                                    o.city = res.city || '';
                                                    o.area = res.district || '';
                                                    o.town = res.town || '';
                                                    o.stre = res.street || '';
                                                    o.numb = res.streetNumber || '';
                                                    o.type = 'ip';
                                                    that.mapG(o);
                                                } else if (sta == 'error') {
                                                    console.log('用户IP定位失败');
                                                    //console.log(res);
                                                    that.req('f`nidili`back`cpos`pos``ip`' + (that.ud.cip || ''));
                                                }
                                            });
                                        }
                                    });
                                }
                            });
                        }
                    });

                    //that.gv.mapWP = that.gv.mapGeo.watchPosition(); // 使用浏览器定位接口监控当前位置，移动端有效
                    //that.gv.mapGeo.clearWatch(that.gv.mapWP); // 取消对当前位置的监控

                });
            });

        } else if (A == 'qq') { // 腾讯地图
            this.gv.mapapi = 'qq';
            a = this.ini.map_qq_js || '';
            this.aj('map_qq', 'https://map.qq.com/api/gljs?v=1.exp&key=' + a, 2, function() {
                that.gv.map = new TMap.Map(document.getElementById('MAP'), {
                    center: new TMap.LatLng(that.ud.gps.lat, that.ud.gps.lon),
                    zoom: that.gv.mapZ
                });
            });

        } else if (A == 'td') { // 天地图
            this.gv.mapapi = 'td';
            a = this.ini.map_td_js || '';
            this.aj('map_tddu', 'http://api.tianditu.gov.cn/api?v=4.0&tk=' + a, 2, function() {
                that.gv.map = new T.Map('MAP');
                that.gv.map.centerAndZoom(new T.LngLat(that.ud.gps.lon, that.ud.gps.lat), that.gv.mapZ);
            });
        } else {
            this.gv.mapapi = '';
            this.msg('未选择地图API');
        }
    },

    // map getLocation
    mapL: function(A) {
        var a, b, c, d, that = this;
        A = A || '北京市';
        if (!A) return;
        if (this.gv.mapapi == 'bd') {
            this.gv.mapCode.getPoint(A, function(res) {
                console.log(res);
                return { lon: res.lng, lat: res.lat };
            });
        } else if (this.gv.mapapi == 'gd') {
            this.gv.mapCode.getLocation(A, function(sta, res) {
                if (sta === 'complete' && res.info === 'OK') {
                    console.log(res);
                    a = res['geocodes'][0]['location'];
                    return { lon: a.lng, lat: a.lat };
                }
            });
        } else if (this.gv.mapapi == 'qq') {

        } else if (this.gv.mapapi == 'td') {

        } else {
            this.msg('未选择地图API');
        }
    },

    // map getAddress
    mapA: function(A, B) {
        var a, b, c, d, that = this;
        if (!A || !B) return;
        if (this.gv.mapapi == 'bd') {
            this.gv.mapCode.getLocation(new BMap.Point(A, B), function(res) {
                console.log(res);
                a = res.addressComponent;
                that.ud.gps.ccod = a.countryCode || 0;
                that.ud.gps.code = a.adcode || 0;
                that.ud.gps.prov = a.province || '';
                that.ud.gps.city = a.city || '';
                that.ud.gps.area = a.district || '';
                that.ud.gps.town = a.township || '';
                that.ud.gps.stre = a.street || '';
                that.ud.gps.numb = a.streetNumber || 0;
                that.ud.gps.addr = res.address;
            });
        } else if (this.gv.mapapi == 'gd') {
            this.gv.mapCode.getAddress([A, B], function(sta, res) {
                if (sta === 'complete' && res.info === 'OK') {
                    console.log(res);
                    a = res.regeocode.addressComponent;
                    that.ud.gps.ccod = a.countryCode || 0;
                    that.ud.gps.code = a.adcode || 0;
                    that.ud.gps.prov = a.province || '';
                    that.ud.gps.city = a.city || '';
                    that.ud.gps.area = a.district || '';
                    that.ud.gps.town = a.township || '';
                    that.ud.gps.stre = a.street || '';
                    that.ud.gps.numb = a.streetNumber || 0;
                    that.ud.gps.addr = res.regeocode.formattedAddress;
                }
            });
        } else if (this.gv.mapapi == 'qq') {

        } else if (this.gv.mapapi == 'td') {

        } else {
            this.msg('未选择地图API');
        }
    },

    // map Geolocation
    mapG: function(A) {
        this.ud.gps.lon = A.lon;
        this.ud.gps.lat = A.lat;
        this.ud.gps.ac = this.d2s(A.lon) + ',' + this.d2s(A.lat);
        this.ud.gps.ac2 = A.lon + ',' + A.lat;
        this.ud.gps.ccod = A.ccod || 0;
        this.ud.gps.code = A.code || 0;
        this.ud.gps.prov = A.prov || '';
        this.ud.gps.city = A.city || '';
        this.ud.gps.area = A.district || '';
        this.ud.gps.town = A.township || '';
        this.ud.gps.stre = A.street || '';
        this.ud.gps.numb = A.streetNumber || 0;
        if (A.type == 'html5') this.ud.gps.type = 'H5';
        else if (A.type == 'sdk') this.ud.gps.type = 'SDK';
        else this.ud.gps.type = 'IP';
        console.log(this.ud.gps);
        this.mapC(A.lon, A.lat);
        this.mapM([
            [A.lon, A.lat, 'pos', '我的位置', 0]
        ]);
    },

    // map center
    mapC: function(A, B) {
        var a, b, c, d, that = this;
        if (!A || !B) return;
        if (this.gv.mapapi == 'bd') {
            that.gv.map.setCenter(new BMap.Point(A, B));
            //that.gv.map.panTo(new BMap.Point(A, B), false);
        } else if (this.gv.mapapi == 'gd') {
            that.gv.map.setCenter([A, B]);
        } else if (this.gv.mapapi == 'qq') {
            that.gv.map.setCenter(A + ',' + B);
        } else if (this.gv.mapapi == 'td') {
            that.gv.map.panTo(B + ',' + A, this.gv.mapZ);
        } else {
            this.msg('未选择地图API');
        }
    },

    // map zoom
    mapZ: function(A) {
        var a, b, c, d, that = this;
        A = A || this.gv.mapZ || 12;
        if (A == '+') A = ++this.gv.mapZ;
        if (A == '-') A = --this.gv.mapZ;
        if (A > 20) A = 20;
        if (A < 3) A = 3;
        if (this.gv.mapapi == 'gd')
            if (A > 18) A = 18;
        this.gv.mapZ = A;
        that.gv.map.setZoom(A);
    },

    // map marker
    mapM: function(A) {
        var a, b, c, d, o, z, that = this;
        o = {};
        a = this.gv.mapico.split(',');
        for (z = 0; z < a.length; z++) {
            o[a[z]] = z + 1;
        }

        for (z = 0; z < A.length; z++) {
            b = {};
            b.lon = A[z][0] || 0;
            b.lat = A[z][1] || 0;
            b.url = c = A[z][2] || '';
            b.txt = A[z][3] || '';
            b.mov = A[z][4] ? true : false;
            b.id = A[z][5] ? A[z][5] : that.rs(6);
            if (o[c]) {
                b.url = 'ico/mapico.png';
                b.x = -15;
                b.y = -30;
                b.w = 30;
                b.h = 30;
                b.ix = 0;
                b.iy = -((o[c] - 1) * 30);
                b.iw = 30;
                b.ih = 1800;
            } else {
                b.x = -15;
                b.y = -30;
                b.w = 30;
                b.h = 30;
                b.ix = 0;
                b.iy = 0;
                b.iw = 30;
                b.ih = 30;
            }

            if (this.gv.mapapi == 'bd') {
                d = new BMap.Marker(new BMap.Point(b.lon, b.lat), {
                    icon: new BMap.Icon(b.url, new BMap.Size(b.w, b.h), {
                        anchor: new BMap.Size(0, 0),
                        imageSize: new BMap.Size(b.iw, b.ih),
                        imageOffset: new BMap.Size(b.ix, b.iy)
                    }),
                    offset: new BMap.Size(b.x, b.y),
                    title: b.txt,
                    enableDragging: b.mov
                });
                this.gv.map.addOverlay(d);
                if (b.id == 'newPosMarker') {
                    if (this.gv.newPosM) this.gv.map.removeOverlay(this.gv.newPosM);
                    this.gv.newPosM = d;
                }
                //console.log(d);

            } else if (this.gv.mapapi == 'gd') {
                d = new AMap.Marker({
                    position: [b.lon, b.lat],
                    icon: new AMap.Icon({
                        size: [b.w, b.h],
                        image: b.url,
                        imageOffset: [b.ix, b.iy],
                        imageSize: [b.iw, b.ih]
                    }),
                    offset: [b.x, b.y],
                    //anchor: 'bottom-center',
                    label: { content: b.txt, direction: 'right', offset: new AMap.Pixel(0, 0) },
                    title: b.txt,
                    draggable: b.mov,
                    extData: { id: b.id }
                });
                this.gv.map.add(d);
                if (b.id == 'newPosMarker') {
                    if (this.gv.newPosM) {
                        //this.gv.newPosM.setMap(null);
                        //this.gv.newPosM = null;
                        this.gv.map.remove(this.gv.newPosM);
                    }
                    this.gv.newPosM = d;
                }
                //console.log(d);
            } else {
                this.msg('添加标注失败');
            }
        }
    },

    // show or hide control
    shCtr: function(A) {
        var a, b, c, d, that = this;
        if (this.gv.mapapi == 'bd') {
            if (A == 'mapEye') A = 'mapGeo';
            if (this.gv[A].isVisible()) {
                this.gv[A].hide();
            } else {
                this.gv[A].show();
            }
        } else if (this.gv.mapapi == 'gd') {
            if (this.gv[A]._config.visible) {
                this.gv[A].hide();
                this.gv[A]._config.visible = false;
            } else {
                this.gv[A].show();
                this.gv[A]._config.visible = true;
            }
        }
    },

    // degree to second
    d2s: function(A) {
        var a, b, c, d, h, m, s, r;
        if (!A) return 0;
        A = A + '';
        A = A.replace('°', ';');
        A = A.replace("'", ';');
        A = A.replace('"', ';');
        A = A.replace(',', ';');
        a = A.split(';');
        b = A.split('.');
        c = a.length;
        d = b.length;
        r = 0;
        if (c > 1) {
            h = (parseInt(a[0] || 0) || 0) * 3600;
            m = (parseInt(a[1] || 0) || 0) * 60;
            s = parseInt(a[2] || 0) || 0;
            r = Math.round(h + m + s);
        } else if (A || d > 1) {
            r = Math.round((parseFloat(A || 0) || 0) * 3600);
        }
        return r;
    },

    // get position distance
    gpd: function(A, B) {
        var a, b, c, e, d, f, g, h, s;
        if (!A || !B) return -1;
        A = ((A + '') || '').split(',');
        B = ((B + '') || '').split(',');
        a = (parseFloat(A[0]) || 0) / 3600;
        b = (parseFloat(A[1]) || 0) / 3600;
        c = (parseFloat(B[0]) || 0) / 3600;
        d = (parseFloat(B[1]) || 0) / 3600;
        e = a * Math.PI / 180.0;
        f = c * Math.PI / 180.0;
        g = e - f;
        h = b * Math.PI / 180.0 - d * Math.PI / 180.0;
        s = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(g / 2), 2) + Math.cos(e) * Math.cos(f) * Math.pow(Math.sin(h / 2), 2)));
        s = s * 6378.137; // EARTH_RADIUS;
        s = Math.round(s * 1000) / 1000; // km
        return s;
    },

    // get position
    gpos: function(A, B) {
        var a, b, c, e, d, f, g, k, u, ip, that = this;
        ip = this.ud.cip || '';
        if (!('geolocation' in navigator)) {
            that.req('f`nidili`back`cpos`pos``ip`' + ip);
            return '';
        }

        if (!A) A = function(err) {
            switch (err.code) {
                case err.PERMISSION_DENIED:
                    that.msg('用户拒绝页面获取地理位置');
                    break;
                case err.POSITION_UNAVAILAVLE:
                    that.msg('无法获取地理位置');
                    that.req('f`nidili`back`cpos`pos``ip`' + ip);
                    break;
                case err.TIMEOUT:
                    that.msg('获取地理位置超时');
                    that.req('f`nidili`back`cpos`pos``ip`' + ip);
                    break;
            }
        };

        if (!B) B = {
            enableHighAccuracy: true, // 是否启动高精模式(布尔值)
            maximumAge: 0, // 1000*60*5设置重新获取位置信息的时间间隔(毫秒)
            timeout: 1000 * 30 // 设置获取定位信息的时间(超时触发ErrorCallback)
        };

        // getCurrentPosition, watchPosition, showClearWatch
        navigator.geolocation.getCurrentPosition(function(pos) {
            that.ud.gps.type = 'H5';
            that.ud.gps.acc = pos.coords.accuracy; // 获取位置的精度
            that.ud.gps.lon = pos.coords.longitude; // 获取经度
            that.ud.gps.lat = pos.coords.latitude; // 获取纬度
            that.ud.gps.alt = pos.coords.altitude; // 获取海拔(米)
            that.ud.gps.alta = pos.coords.altitudeAccuracy; // 获取位置的海拔精度
            that.ud.gps.head = pos.coords.heading; // 获取方向
            that.ud.gps.spd = pos.coords.speed; // 获取速度
            that.ud.gps.time = pos.timestamp; // 获取相应的时间
            if (that.ud.gps.lon && that.ud.gps.lat) {
                that.ud.gps.ac = that.d2s(that.ud.gps.lon) + ',' + that.d2s(that.ud.gps.lat); // active coordinate
                that.ud.gps.ac2 = that.ud.gps.lon + ',' + that.ud.gps.lat; // active coordinate
                that.msg('您的坐标(秒)：' + that.ud.gps.ac);
                that.msg('您的坐标(度)：' + that.ud.gps.ac2);
                that.req('f`nidili`back`cpos`pos`' + that.ud.gps.ac2 + '`ip`' + ip);
            }
        }, A, B);
    },

    // get gps for image
    ggfi: function(A) {
        var f, g, l, o, s, t, u, z;
        o = this.gn(A);
        o.onchange = function() {
            g = this.files;
            l = g.length;
            for (z = 0; z < l; z++) {
                f = g[z] || null;
                if (!f) continue;
                //alert([f, f.name, f.size, f.type, f.lastModified, f.lastModifiedDate]);return;
                t = (f.type || '').split('/');
                if (t[0] != 'image') continue;
                u = URL.createObjectURL(f);
                s = '<img src="' + (u || '') + '" onload="ryo.gexif(this, \'g\')"/>';
                this.gv.TMP.innerHTML = s;
            }
        };
    },

    // get exif
    gexif: function(A, B, C) {
        var a, o, p, t, u, ip, that = this;
        ip = this.ud.cip || '';
        A = this.gn(A);
        B = B || 'g';
        if (!A) return;
        o = {};
        EXIF.getData(A,
            function() {
                if (B == 'g') {
                    o.lon = EXIF.getTag(this, 'GPSLongitude');
                    o.lat = EXIF.getTag(this, 'GPSLatitude');
                    that.ud.gps.lon = o.lon = Math.round(((o.lon[0] || 0) + (o.lon[1] || 0) / 60 + (o.lon[2] || 0) / 3600) * 10000) / 10000;
                    that.ud.gps.lat = o.lat = Math.round(((o.lat[0] || 0) + (o.lat[1] || 0) / 60 + (o.lat[2] || 0) / 3600) * 10000) / 10000;
                    //p = EXIF.getAllTags(this);
                    //console.log(o);
                    //console.log(p);
                    that.gv.wd.URL.revokeObjectURL(A.src);
                    if (that.ud.gps.lon && that.ud.gps.lat) {
                        that.ud.gps.ac = that.d2s(that.ud.gps.lon) + ',' + that.d2s(that.ud.gps.lat); // active coordinate
                        that.ud.gps.ac2 = that.ud.gps.lon + ',' + that.ud.gps.lat; // active coordinate
                    }
                    that.msg('您的坐标(秒)：' + that.ud.gps.ac);
                    that.msg('您的坐标(度)：' + that.ud.gps.ac2);
                    that.req('f`nidili`back`cpos`pos`' + that.ud.gps.ac2 + '`ip`' + ip);

                } else if (B == 'o') { // Orientation
                    a = EXIF.getTag(this, 'Orientation') || 1;
                    C(a);
                }
            });
    },

    // current position
    cpos: function(A) {
        var a, b, c, d, e, f, l, z;
        l = this.ud.lg || 'cn';
        f = LANG[l]['num'];
        e = '156';
        for (z in f) {
            if (f[z] == l) {
                e = z;
                break;
            }
        }
        d = A.addr || '';
        this.ud.gps.code = e + (A.code || '');
        this.ud.gps.prov = A.prov || '';
        this.ud.gps.city = A.city || '';
        this.ud.gps.area = A.area || '';
        this.ud.gps.town = A.town || '';
        this.ud.gps.type = A.type || 'IP';
        c = d.split(this.ud.gps.town);
        this.ud.gps.ap = c[1] || this.ud.gps.town || this.ud.gps.area || this.ud.gps.city || this.ud.gps.prov || '';
        this.ud.gps.ap = this.ud.gps.code + this.ud.gps.ap;
        this.msg('您的位置：' + this.a2a(this.ud.gps.ap, 5));
        this.gmsg();
        //console.log(this.ud.gps);
    },

    // area to addr
    a2a: function(A, B) {
        var a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, u, v, z;
        A = A || '';
        B = B || 0;
        if (!A) return '';
        l = this.ud.lg || 'cn';
        k = LANG[l]['a'];
        u = LANG[l]['lg'];
        v = LANG[l]['num'];
        A = A.split(',');
        l = A.length;
        r = [];
        if (!k) return '';

        for (z = 0; z < l; z++) {
            i = A[z] || '';
            m = i.substr(0, 3) || '';
            a = i.substr(3, 2) || '';
            b = i.substr(5, 2) || '';
            c = i.substr(7, 2) || '';
            d = i.substr(9) || '';
            n = o = p = q = '';
            s = [];
            if (u && v) n = u[v[m]];
            else n = '';

            e = k.split('~' + a + '~', 2);
            f = (e[1] || '').split('``', 2);
            if (f.length > 1) {
                o = f[0] || '';
                s.unshift(o);
            }

            e = k.split('``' + a + '`', 2);
            f = (e[1] || '').split('``', 2);
            if (f.length > 1) {
                g = this.obj(f[0], 1, '`');
                p = g[b] || '';
                s.unshift(p);
            }

            e = k.split('``' + a + b + '`', 2);
            f = (e[1] || '').split('``', 2);
            if (f.length > 1) {
                g = this.obj(f[0], 1, '`');
                q = g[c] || '';
                s.unshift(q);
            }

            if (d) s.unshift(d);
            s = s.join('&lt;') || '';
            if (B == 0) s = n;
            else if (B == 1) s = o;
            else if (B == 2) s = p ? p + (o ? '&lt;' + o : '') : o;
            else if (B == 3) s = q ? q + (p ? '&lt;' + p : '') : p;
            else if (B == 4) s = d ? d + (q ? '&lt;' + q : '') : q;
            else if (B == 5) s = d ? d + (q ? '&lt;' + q : '') + (p ? '&lt;' + p : '') : q ? q + (p ? '&lt;' + p : '') : p;
            r.push(s);
        }
        r = r.join(', ') || '';
        return r;
    },

    // get msg
    gmsg: function() {
        var a = b = c = '',
            d = parseInt(this.ini.gmsg) || 3;
        if (this.ud.gps.code) a = '`aa`' + this.e36(this.ud.gps.code) || ''; // active area
        if (this.ud.gps.ac) b = '`ac`' + this.e36(this.ud.gps.ac) || ''; // active coordinate
        if (this.ud.gps.ap) c = '`ap`' + this.e36(this.ud.gps.ap) || ''; // active position
        this.req('f`gmsg' + a + b + c);
        if (this.ud.gmsg) clearTimeout(this.ud.gmsg);
        this.ud.gmsg = setTimeout(this.gmsg, 1000 * 60 * d);
    },

    // set msg
    smsg: function() {
        var a, b, c, d, z;
        if (!this.ud.smsg) return '';
        a = this.obj(this.ud.smsg || '');
        for (z in a) {
            b = this.gn('mn_' + z);
            if (!b) continue;
            c = parseInt(a[z]) || 0;
            d = this.nfmt(c);
            if (d > 0) {
                this.nt(b, d);
                b.className = 'amt';
            } else {
                this.nt(b, '');
                b.className = '';
            }
        }
    },

    // recharge preferential
    recp: function() {
        var a, b, c, d, e, f, l, s, z;
        a = this.ini.recp;
        if (!a) return;
        a = a.split(/ *, */);
        b = a.length;
        s = [];
        for (z = 0; z < b; z += 2) {
            c = parseInt(a[z]);
            d = parseFloat(a[z + 1]);
            e = c * d / 10;
            s.push('<i class="recp" onclick="this.req(\'f`ta`org`we`sum`' + e + '`rp`1\')">&yen;' + c + ' * ' + d + '折 = &yen;' + e + '</i>');
        }
        s = s.join('') + '<i class="cf"></i>';
        l = this.ud.lg || 'cn';
        s = s + '<i class="recTxt">' + this.sc(LANG[l]['dt']['recp']) + '</i>';
        s = s.replace('EEFAAPAY', '<img class="payImg" src="img/sys/eefaa_wc_pay.jpg"/>');
        s = '<i class="ldListB vdCtt">' + s + '</i>';
        this.vd('充值优惠活动', s);
    },

    // QR Code pay
    qrpay: function(A) {
        var o, s, t, that;
        that = this;
        if (!A) return this.msg('参数缺失！');
        o = this.obj(A);
        if (this.pgobj) {
            wx.requestPayment({
                'appId': o.aid,
                'timeStamp': o.tm,
                'nonceStr': o.rs,
                'package': 'prepay_id=' + o.pid,
                'paySign': o.ps,
                'signType': o.stp,
                'success': function(res) {
                    that.req('f`qos`org`' + (o.org || '') + '`num`' + (o.num || ''));
                    that.msg('正在查询订单，请稍等...');
                    console.log('success', res);
                },
                'fail': function(res) {
                    that.msg('充值失败！');
                    console.log('fail', res);
                },
                'complete': function(res) {
                    console.log('complete', res);
                }
            })

        } else {

            if (this.ini.ismob) {
                this.npg(o.qurl);
            } else {
                t = '<p>&yen;: ' + (parseFloat(o.sum) || 0) + ' ' + (o.des || '') + ' 请在10分钟内完成支付' + (o.qurl ? '，若扫码失败可点击支付链接进行支付: <a href="' + (o.qurl || 'null') + '" target="_blank">支付链接</a>' : '');
                s = '<i class="qrpay"><img src="qr.php?data=' + (o.qurl || '') + '"/><i class="qrtxt">' + t + '</i></i></p>';
                this.nw('id`nwPay`nm`支付`ctt`' + this.e36(s));
                this.qos('org`' + (o.org || '') + '`num`' + (o.num || ''));
            }
        }
    },

    // query order state
    qos: function(A) {
        var i, o, that = this;
        o = this.obj(A);
        i = this.ud[o.num] || 0
        if (!i) this.ud[o.num] = 0;
        if (++i > 18) return;
        setTimeout(function() {
            that.req('f`qos`org`' + (o.org || '') + '`num`' + (o.num || ''));
        }, 10 * 1000);
    },

    // draw image
    dimg: function(A, B) {
        var a, b, c, d, cvs, ctx, img, that;
        that = this;
        A = A || {};
        A.src = A.src || '';
        if (!A.src) return that.msg('图像资源错误！');
        A.sx = parseInt(A.sx) || 0;
        A.sy = parseInt(A.sy) || 0;
        A.sw = parseInt(A.sw) || 0;
        A.sh = parseInt(A.sh) || 0;
        A.dx = parseInt(A.dx) || 0;
        A.dy = parseInt(A.dy) || 0;
        A.dw = parseInt(A.dw) || 0;
        A.dh = parseInt(A.dh) || 0;
        A.t = A.t || 'png';
        A.q = A.q || 0.92;

        A.cvs = cvs = that.gv['hideCVS'];
        ctx = that.gv['hideCVS_ctx'];
        if (!cvs || !ctx) return that.msg('canvas对象错误！');
        img = cvs.createImage();
        console.log(cvs, ctx);

        a = src.substr(0, 4);
    },

    // canvas to temp filePath
    cttf: function(A, B) {
        var x, y, w, h, dw, dh, c, t, q, that;
        that = this;
        A = A || {};
    },

    // save image
    simg: function(A) {
        var a, b, c, d, w, h, x, y, l, t, cvs, ctx, img, that;
        that = this;
        A = A || '';
        a = A.substr(0, 4);
    },

    popdl: function(A) {
        var a, b, c, d, o, s;
        a = this.obj(A);
        if (!a) return this.msg('无效链接！');
        if (this.pgobj) {
            this.pgobj.setData({
                dlink: a.dlink,
                fsize: a.fsize
            })
            this.sn('down');
        } else {
            s = '<p>点击或复制下载链接前往下载(' + (a.fsize || '') + ')：<a href="' + (a.dlink || '') + '" target="_blank>' + (a.dlink || '') + '</a></p>';
            o = {};
            o.nm = '下载';
            o.ctt = s;
            this.nw(o);
        }
    },

    tpl: {
        user: '<i tp="list" class="list vmList userList" style="{{bgc}}"><i class="userInfo uilr"><i class="avaBox"><img class="ava" src="{{user_ava}}" title="{{NL_user_ava}}" onclick="ryo.gd(\'f`vd`tb`user`kw`uni.{{user_uni}}\'); ryo.se()"></img><i class="avaIco"><i class="ico15 icoGen_{{PN_user_gen}}" title="{{NL_user_gen}}: {{S1_user_gen}}"></i><i class="ico15 icoAtp_{{PN_user_atp}}" title="{{NL_user_atp}}: {{S1_user_atp}}"></i><i class="ico15 icoRl" title="{{NL_user_rl}}: {{user_rl}}">{{user_rl}}</i><i class="ico15 icoCl" title="{{NL_user_atp}}: {{user_cl}}">{{user_cl}}</i></i></i><i class="unBox"><i class="unTxt" title="{{NL_user_un}}：{{user_un}}，{{NL_user_nn}}：{{user_nn}}" onclick="ryo.gd(\'f`vd`tb`user`kw`uni.{{user_uni}}\'); ryo.se()">[{{user_un}}] {{user_nn}}</i><i class="icoBox icoBox30"><i id="fans_atts{{user_uni}}" class="icoTxt" title="{{NL_user_fans}}: {{user_fans}}"><i class="ico30 icoFans"></i>{{NF_user_fans}}</i><i id="atts{{user_uni}}" class="icoTxt{{SS_user_atts}}" title="{{NL_user_att}}: {{user_att}}" onclick="ryo.req(\'f`ulog`uid2`{{user_id}}`tp`1`back`ss`nid`atts{{user_uni}}\'); ryo.se()"><i class="ico30 icoAtt"></i>{{NF_user_att}}</i><i class="icoTxt" title="distance|距离: {{GPD_user_ac}} km"><i class="ico30 icoDis"></i>{{GPD_ac}} km</i></i></i></i></i>',

        userCtt: '<i class="userCttCtn"><i style="{{bgc}}" class="userInfo uilr"><i class="avaBox"><img class="ava" src="{{user_ava}}" title="{{NL_user_ava}}" onclick="ryo.gd(\'f`vd`tb`user`kw`uni.{{user_uni}}\'); ryo.se()"></img><i class="avaIco"><i class="ico15 icoGen_{{PN_user_gen}}" title="{{NL_user_gen}}: {{S1_user_gen}}"></i><i class="ico15 icoAtp_{{PN_user_atp}}" title="{{NL_user_atp}}: {{S1_user_atp}}"></i><i class="ico15 icoRl" title="{{NL_user_rl}}: {{user_rl}}">{{user_rl}}</i><i class="ico15 icoCl" title="{{NL_user_atp}}: {{user_cl}}">{{user_cl}}</i></i></i><i class="unBox"><i class="unTxt" title="{{NL_user_un}}：{{user_un}}，{{NL_user_nn}}：{{user_nn}}" onclick="ryo.gd(\'f`vd`tb`user`kw`uni.{{user_uni}}\'); ryo.se()">[{{user_un}}] {{user_nn}}</i><i class="icoBox icoBox30"><i id="fans_cttAtts{{user_uni}}" class="icoTxt" title="{{NL_user_fans}}: {{user_fans}}"><i class="ico30 icoFans"></i>{{NF_user_fans}}</i><i id="cttAtts{{user_uni}}" class="icoTxt{{SS_user_atts}}" title="{{NL_user_att}}: {{user_att}}" onclick="ryo.req(\'f`ulog`uid2`{{user_id}}`tp`1`back`ss`nid`cttAtts{{user_uni}}\'); ryo.se()"><i class="ico30 icoAtt"></i>{{NF_user_att}}</i><i class="icoTxt" title="distance|距离: {{GPD_user_ac}} km"><i class="ico30 icoDis"></i>{{GPD_ac}} km</i></i></i></i><i class="userCtt"><i class="userCttBox"><i class="userCttLab">sect|门派</i><i class="userCttLB"><i class="userCttNv"><i class="userCttN">{{NL_user_on}}</i><i class="userCttV">{{user_on}}</i></i><i class="userCttNv"><i class="userCttN">{{NL_user_op}}(人)</i><i class="userCttV">{{user_op}}(人)</i></i><i class="userCttNv"><i class="userCttN">{{NL_user_gprt}}</i><i class="userCttV">{{user_gprt}}</i></i><i class="userCttNv"><i class="userCttN">{{NL_user_prt}}</i><i class="userCttV">{{user_prt}}</i></i><i class="userCttNv"><i class="userCttN">{{NL_user_sn}}</i><i class="userCttV">{{user_sn}}</i></i><i class="userCttNv"><i class="userCttN">{{NL_user_sp}}(人)</i><i class="userCttV">{{user_sp}}(人)</i></i><i class="userCttNv"><i class="userCttN">{{NL_user_prti}}(人)</i><i class="userCttV">{{user_prti}}(人)</i></i><i class="userCttNv"><i class="userCttN">{{NL_user_gson}}(人)</i><i class="userCttV">{{user_gson}}(人)</i></i></i></i><i class="userCttBox{{HI_user_job}}"><i class="userCttLab">{{NL_user_job}}</i><i class="userCttLB">{{LIST_user_job}}</i></i><i class="userCttBox{{HI_user_adv}}"><i class="userCttLab">{{NL_user_adv}}</i><i class="userCttLB">{{LIST_user_adv}}</i></i><i class="userCttBox{{HI_user_dyna}}"><i class="userCttLab">{{NL_user_dyna}}</i><i class="userCttLB">{{LIST_user_dyna}}</i></i><i class="userCttBox{{HI_user_eshop}}"><i class="userCttLab">{{NL_user_eshop}}</i><i class="userCttLB">{{LIST_user_eshop}}</i></i><i class="userCttBox{{HI_user_oshop}}"><i class="userCttLab">{{NL_user_oshop}}</i><i class="userCttLB">{{LIST_user_oshop}}</i></i><i class="userCttBox{{HI_user_stall}}"><i class="userCttLab">{{NL_user_stall}}</i><i class="userCttLB">{{LIST_user_stall}}</i></i><i class="userCttBox"><i class="userCttLab">userProfile|个人简介</i><i class="userCttLB"><i class="userCttTxt">{{NL_user_dic}}：{{user_dic}}<br/>{{NL_user_pro}}：{{user_pro}}</i></i></i><i class="userCttBox"><i class="userCttLab">media|媒体账号</i><i class="userCttLB"><i class="userCttTxt">{{NL_user_wbnick}}：{{user_wbnick}}<br/>{{NL_user_wburl}}：<a href="{{user_wburl}}" target="_blank">{{user_wburl}}</a></i><i class="userCttTxt">{{NL_user_dynick}}：{{user_dynick}}<br/>{{NL_user_dyurl}}：<a href="{{user_dyurl}}" target="_blank">{{user_dyurl}}</a></i><i class="userCttTxt">{{NL_user_xgnick}}：{{user_xgnick}}<br/>{{NL_user_xgurl}}：<a href="{{user_xgurl}}" target="_blank">{{user_xgurl}}</a></i><i class="userCttTxt">{{NL_user_txnick}}：{{user_txnick}}<br/>{{NL_user_txurl}}：<a href="{{user_txurl}}" target="_blank">{{user_txurl}}</a></i><i class="userCttTxt">{{NL_user_other}}：{{LK_user_other}}</i></i></i></i></i>',

        dyna: '<i class="list vmList dynaList" style="{{bgc}}"><i class="lBox"><i class="userInfo uitb"><i class="avaBox"><img class="ava" src="{{user_ava}}" title="{{NL_user_ava}}" onclick="ryo.gd(\'f`vd`tb`user`kw`uni.{{user_uni}}\'); ryo.se()"></img><i class="avaIco"><i class="ico15 icoGen_{{PN_user_gen}}" title="{{NL_user_gen}}: {{S1_user_gen}}"></i><i class="ico15 icoAtp_{{PN_user_atp}}" title="{{NL_user_atp}}: {{S1_user_atp}}"></i><i class="ico15 icoRl" title="{{NL_user_rl}}: {{user_rl}}">{{user_rl}}</i><i class="ico15 icoCl" title="{{NL_user_cl}}: {{user_cl}}">{{user_cl}}</i></i></i><i class="unBox"><i class="unTxt" title="{{NL_user_un}}：{{user_un}}，{{NL_user_nn}}：{{user_nn}}" onclick="ryo.gd(\'f`vd`tb`user`kw`uni.{{user_uni}}\'); ryo.se()">{{user_nn}}</i></i></i></i><i class="rBox"><i style="{{bgc}}" class="desBox" onclick="ryo.gd(\'f`vd`tb`dyna`kw`uni.{{uni}}`ctn`{{uni}}`tpl`dynaCtt\'); ryo.se()"><i class="pvpic"></i><i class="des">{{des}}</i></i><i class="icoBox icoBox20"><i class="icoTxt" title="{{NL_rh}}: {{rh}}"><i class="ico20 icoRh"></i>{{NF_rh}}</i><i class="icoTxt" title="{{NL_vict}}: {{vict}}"><i class="ico20 icoVc"></i>{{NF_vict}}</i><i class="icoTxt" title="{{NL_coct}}: {{coct}}"><i class="ico20 icoCc"></i>{{NF_coct}}</i><i id="pras{{uni}}" class="icoTxt{{SS_pras}}" title="{{NL_prct}}: {{prct}}" onclick="ryo.req(\'f`dlog`tb`dyna`uid2`{{user_id}}`did`{{id}}`tp`3`back`ss`nid`pras{{uni}}\'); ryo.se()"><i class="ico20 icoPc"></i>{{NF_prct}}</i></i></i></i>',

        dynaCtt: '<i class="dynaCttCtn"><i style="{{bgc}}" class="userInfo uilr"><i class="avaBox"><img class="ava" src="{{user_ava}}" title="{{NL_user_ava}}" onclick="ryo.gd(\'f`vd`tb`user`kw`uni.{{user_uni}}\'); ryo.se()"></img><i class="avaIco"><i class="ico15 icoGen_{{PN_user_gen}}" title="{{NL_user_gen}}: {{S1_user_gen}}"></i><i class="ico15 icoAtp_{{PN_user_atp}}" title="{{NL_user_atp}}: {{S1_user_atp}}"></i><i class="ico15 icoRl" title="{{NL_user_rl}}: {{user_rl}}">{{user_rl}}</i><i class="ico15 icoCl" title="{{NL_user_atp}}: {{user_cl}}">{{user_cl}}</i></i></i><i class="unBox"><i class="unTxt" title="{{NL_user_un}}：{{user_un}}，{{NL_user_nn}}：{{user_nn}}" onclick="ryo.gd(\'f`vd`tb`user`kw`uni.{{user_uni}}\'); ryo.se()">[{{user_un}}] {{user_nn}}</i><i class="icoBox icoBox30"><i id="fans_cttAtts{{uni}}" class="icoTxt" title="{{NL_user_fans}}: {{user_fans}}"><i class="ico30 icoFans"></i>{{NF_user_fans}}</i><i id="cttAtts{{uni}}" class="icoTxt{{SS_atts}}" title="{{NL_user_att}}: {{user_att}}" onclick="ryo.req(\'f`ulog`uid2`{{user_id}}`tp`1`back`ss`nid`cttAtts{{uni}}\'); ryo.se()"><i class="ico30 icoAtt"></i>{{NF_user_att}}</i><i class="icoTxt" title="distance|距离: {{GPD_user_ac}} km"><i class="ico30 icoDis"></i>{{GPD_ac}} km</i></i></i></i><i class="dynaCtt">{{ctt}}</i><i class="icoBox icoBox20"><i class="icoTxt" title="{{NL_rh}}: {{rh}}"><i class="ico20 icoRh"></i>{{NF_rh}}</i><i class="icoTxt" title="{{NL_vict}}: {{vict}}"><i class="ico20 icoVc"></i>{{NF_vict}}</i><i class="icoTxt" title="{{NL_coct}}: {{coct}}"><i class="ico20 icoCc"></i>{{NF_coct}}</i><i id="cttPras{{uni}}" class="icoTxt{{SS_pras}}" msg="{{NL_prct}}: " title="{{NL_prct}}: {{prct}}" onclick="ryo.req(\'f`dlog`tb`dyna`uid2`{{user_id}}`did`{{id}}`tp`3`back`ss`nid`cttPras{{uni}}\'); ryo.se()"><i class="ico20 icoPc"></i>{{NF_prct}}</i><i id="cttFavs{{uni}}" class="icoTxt{{SS_favs}}" msg="{{NL_fact}}: " title="{{NL_fact}}: {{fact}}" onclick="ryo.req(\'f`dlog`tb`dyna`uid2`{{user_id}}`did`{{id}}`tp`4`back`ss`nid`cttFavs{{uni}}\'); ryo.se()"><i class="ico20 icoFc"></i>{{NF_fact}}</i></i></i>',

        game: '<i class="list vmList dynaList" style="{{bgc}}"><i class="lBox"><i class="userInfo uitb"><i class="avaBox"><img class="ava" src="{{user_ava}}" title="{{NL_user_ava}}" onclick="ryo.gd(\'f`vd`tb`user`kw`uni.{{user_uni}}\'); ryo.se()"></img><i class="avaIco"><i class="ico15 icoGen_{{PN_user_gen}}" title="{{NL_user_gen}}: {{S1_user_gen}}"></i><i class="ico15 icoAtp_{{PN_user_atp}}" title="{{NL_user_atp}}: {{S1_user_atp}}"></i><i class="ico15 icoRl" title="{{NL_user_rl}}: {{user_rl}}">{{user_rl}}</i><i class="ico15 icoCl" title="{{NL_user_cl}}: {{user_cl}}">{{user_cl}}</i></i></i><i class="unBox"><i class="unTxt" title="{{NL_user_un}}：{{user_un}}，{{NL_user_nn}}：{{user_nn}}" onclick="ryo.gd(\'f`vd`tb`user`kw`uni.{{user_uni}}\'); ryo.se()">{{user_nn}}</i></i></i></i><i class="rBox"><i style="{{bgc}}" class="desBox" onclick="ryo.gv.guni=\'{{uni}}\'; ryo.gd(\'f`vd`tb`game`kw`uni.{{uni}}`ctn`{{uni}}`tpl`gameCtt\'); ryo.se()"><i class="pvpic"></i><i class="des">{{des}}</i></i><i class="icoBox icoBox20"><i class="icoTxt" title="{{NL_rh}}: {{rh}}"><i class="ico20 icoRh"></i>{{NF_rh}}</i><i class="icoTxt" title="{{NL_vict}}: {{vict}}"><i class="ico20 icoVc"></i>{{NF_vict}}</i><i class="icoTxt" title="{{NL_coct}}: {{coct}}"><i class="ico20 icoCc"></i>{{NF_coct}}</i><i id="pras{{uni}}" class="icoTxt{{SS_pras}}" title="{{NL_prct}}: {{prct}}" onclick="ryo.req(\'f`dlog`tb`game`uid2`{{user_id}}`did`{{id}}`tp`3`back`ss`nid`pras{{uni}}\'); ryo.se()"><i class="ico20 icoPc"></i>{{NF_prct}}</i></i></i></i>',

        gameList: '<i class="list vmList gameList" style="{{bgc}}"><i class="gmBox"><i style="{{bgc}}" class="gmCtt" onclick="ryo.gv.guni=\'{{uni}}\'; ryo.gd(\'f`vd`tb`game`kw`uni.{{uni}}`ctn`{{uni}}`tpl`gameDes\'); ryo.se()"><img class="logo" src="{{logo}}"></img><i class="name">{{tit}}</i></i><i class="icoBox icoBox20"><i class="icoTxt" title="{{NL_rh}}: {{rh}}"><i class="ico20 icoRh"></i>{{NF_rh}}</i><i class="icoTxt" title="{{NL_vict}}: {{vict}}"><i class="ico20 icoVc"></i>{{NF_vict}}</i><i class="icoTxt" title="{{NL_coct}}: {{coct}}"><i class="ico20 icoCc"></i>{{NF_coct}}</i><i id="pras{{uni}}" class="icoTxt{{SS_pras}}" title="{{NL_prct}}: {{prct}}" onclick="ryo.req(\'f`dlog`tb`game`uid2`{{user_id}}`did`{{id}}`tp`3`back`ss`nid`pras{{uni}}\'); ryo.se()"><i class="ico20 icoPc"></i>{{NF_prct}}</i></i></i></i>',

        gameDes: '<i class="dynaCttCtn"><i style="{{bgc}}" class="userInfo uilr"><i class="avaBox"><img class="ava" src="{{user_ava}}" title="{{NL_user_ava}}" onclick="ryo.gd(\'f`vd`tb`user`kw`uni.{{user_uni}}\'); ryo.se()"></img><i class="avaIco"><i class="ico15 icoGen_{{PN_user_gen}}" title="{{NL_user_gen}}: {{S1_user_gen}}"></i><i class="ico15 icoAtp_{{PN_user_atp}}" title="{{NL_user_atp}}: {{S1_user_atp}}"></i><i class="ico15 icoRl" title="{{NL_user_rl}}: {{user_rl}}">{{user_rl}}</i><i class="ico15 icoCl" title="{{NL_user_atp}}: {{user_cl}}">{{user_cl}}</i></i></i><i class="unBox"><i class="unTxt" title="{{NL_user_un}}：{{user_un}}，{{NL_user_nn}}：{{user_nn}}" onclick="ryo.gd(\'f`vd`tb`user`kw`uni.{{user_uni}}\'); ryo.se()">[{{user_un}}] {{user_nn}}</i><i class="icoBox icoBox30"><i id="fans_cttAtts{{uni}}" class="icoTxt" title="{{NL_user_fans}}: {{user_fans}}"><i class="ico30 icoFans"></i>{{NF_user_fans}}</i><i id="cttAtts{{uni}}" class="icoTxt{{SS_atts}}" title="{{NL_user_att}}: {{user_att}}" onclick="ryo.req(\'f`ulog`uid2`{{user_id}}`tp`1`back`ss`nid`cttAtts{{uni}}\'); ryo.se()"><i class="ico30 icoAtt"></i>{{NF_user_att}}</i><i class="icoTxt" title="distance|距离: {{GPD_user_ac}} km"><i class="ico30 icoDis"></i>{{GPD_ac}} km</i></i></i></i><i class="gameAtt"><i class="tdBox tds2"><i class="td td1">游戏平台：{{ptp}}</i><i class="td td2">游戏类目：{{cat}}</i></i><i class="tdBox tds2"><i class="td td1">师傅奖励：{{prper}}%</i><i class="td td2">师祖奖励：{{grper}}%</i></i><i class="tdBox tds2"><i class="td td1">游戏大小：{{fs}} MB</i><i class="td td2" onclick="ryo.npg(\'{{lk}}\');">下载链接(点击下载)：{{lk}}</i></i></i><i class="vdoBox"><video id="vdoPlayer" controls preload="auto" poster="{{vpv}}"><source src="{{vdo}}" type="video/mp4" /></video></i><i class="dynaCtt">{{ctt}}</i><i class="icoBox icoBox20"><i class="icoTxt" title="{{NL_rh}}: {{rh}}"><i class="ico20 icoRh"></i>{{NF_rh}}</i><i class="icoTxt" title="{{NL_vict}}: {{vict}}"><i class="ico20 icoVc"></i>{{NF_vict}}</i><i class="icoTxt" title="{{NL_coct}}: {{coct}}"><i class="ico20 icoCc"></i>{{NF_coct}}</i><i id="cttPras{{uni}}" class="icoTxt{{SS_pras}}" msg="{{NL_prct}}: " title="{{NL_prct}}: {{prct}}" onclick="ryo.req(\'f`dlog`tb`game`uid2`{{user_id}}`did`{{id}}`tp`3`back`ss`nid`cttPras{{uni}}\'); ryo.se()"><i class="ico20 icoPc"></i>{{NF_prct}}</i><i id="cttFavs{{uni}}" class="icoTxt{{SS_favs}}" msg="{{NL_fact}}: " title="{{NL_fact}}: {{fact}}" onclick="ryo.req(\'f`dlog`tb`game`uid2`{{user_id}}`did`{{id}}`tp`4`back`ss`nid`cttFavs{{uni}}\'); ryo.se()"><i class="ico20 icoFc"></i>{{NF_fact}}</i></i></i>',

        gameCtt: '<i class="dynaCttCtn"><i style="{{bgc}}" class="userInfo uilr"><i class="avaBox"><img class="ava" src="{{user_ava}}" title="{{NL_user_ava}}" onclick="ryo.gd(\'f`vd`tb`user`kw`uni.{{user_uni}}\'); ryo.se()"></img><i class="avaIco"><i class="ico15 icoGen_{{PN_user_gen}}" title="{{NL_user_gen}}: {{S1_user_gen}}"></i><i class="ico15 icoAtp_{{PN_user_atp}}" title="{{NL_user_atp}}: {{S1_user_atp}}"></i><i class="ico15 icoRl" title="{{NL_user_rl}}: {{user_rl}}">{{user_rl}}</i><i class="ico15 icoCl" title="{{NL_user_atp}}: {{user_cl}}">{{user_cl}}</i></i></i><i class="unBox"><i class="unTxt" title="{{NL_user_un}}：{{user_un}}，{{NL_user_nn}}：{{user_nn}}" onclick="ryo.gd(\'f`vd`tb`user`kw`uni.{{user_uni}}\'); ryo.se()">[{{user_un}}] {{user_nn}}</i><i class="icoBox icoBox30"><i id="fans_cttAtts{{uni}}" class="icoTxt" title="{{NL_user_fans}}: {{user_fans}}"><i class="ico30 icoFans"></i>{{NF_user_fans}}</i><i id="cttAtts{{uni}}" class="icoTxt{{SS_atts}}" title="{{NL_user_att}}: {{user_att}}" onclick="ryo.req(\'f`ulog`uid2`{{user_id}}`tp`1`back`ss`nid`cttAtts{{uni}}\'); ryo.se()"><i class="ico30 icoAtt"></i>{{NF_user_att}}</i><i class="icoTxt" title="distance|距离: {{GPD_user_ac}} km"><i class="ico30 icoDis"></i>{{GPD_ac}} km</i></i></i></i><i class="dynaCtt">{{ctt}}</i><i class="icoBox icoBox20"><i class="icoTxt" title="{{NL_rh}}: {{rh}}"><i class="ico20 icoRh"></i>{{NF_rh}}</i><i class="icoTxt" title="{{NL_vict}}: {{vict}}"><i class="ico20 icoVc"></i>{{NF_vict}}</i><i class="icoTxt" title="{{NL_coct}}: {{coct}}"><i class="ico20 icoCc"></i>{{NF_coct}}</i><i id="cttPras{{uni}}" class="icoTxt{{SS_pras}}" msg="{{NL_prct}}: " title="{{NL_prct}}: {{prct}}" onclick="ryo.req(\'f`dlog`tb`game`uid2`{{user_id}}`did`{{id}}`tp`3`back`ss`nid`cttPras{{uni}}\'); ryo.se()"><i class="ico20 icoPc"></i>{{NF_prct}}</i><i id="cttFavs{{uni}}" class="icoTxt{{SS_favs}}" msg="{{NL_fact}}: " title="{{NL_fact}}: {{fact}}" onclick="ryo.req(\'f`dlog`tb`game`uid2`{{user_id}}`did`{{id}}`tp`4`back`ss`nid`cttFavs{{uni}}\'); ryo.se()"><i class="ico20 icoFc"></i>{{NF_fact}}</i></i></i>',

        top: '<i class="list vmList topList" style="{{bgc}}"><i class="userInfo uilr"><i class="avaBox"><img class="ava" src="{{user_ava}}" title="{{NL_user_ava}}" onclick="ryo.gd(\'f`vd`tb`user`kw`uni.{{user_uni}}\'); ryo.se()"></img><i class="avaIco"><i class="ico15 icoGen_{{PN_user_gen}}" title="{{NL_user_gen}}: {{S1_user_gen}}"></i><i class="ico15 icoAtp_{{PN_user_atp}}" title="{{NL_user_atp}}: {{S1_user_atp}}"></i><i class="ico15 icoRl" title="{{NL_user_rl}}: {{user_rl}}">{{user_rl}}</i><i class="ico15 icoCl" title="{{NL_user_atp}}: {{user_cl}}">{{user_cl}}</i></i></i><i class="unBox"><i class="tdBox tr1 tds3"><i class="td td1" title="rank|排名">排名</i><i class="td td2" title="{{NL_user_nn}}">{{PY_user_nn}}</i><i class="td td3" title="{{NL_stat}}">统计</i></i><i class="tdBox tr2 tds3"><i class="td td1">{{lnum}}</i><i class="td td2" title="{{NL_user_un}}：{{user_un}}，{{NL_user_nn}}：{{user_nn}}" onclick="ryo.gd(\'f`vd`tb`user`kw`uni.{{user_uni}}\'); ryo.se()">{{user_nn}}</i><i class="td td3" title="{{stat}}">{{NF_stat}}</i></i></i></i></i>',

        myinfo: '<i tp="list" class="list vmList myinfo {{attKey}}Box" style="{{bgc}}"><i class="muiLbox" onclick="ryo.nmn(\'mnTool.ava\', \'TB\'); ryo.ws(\'TB\', 1)"><img id="{{attKey}}" src="{{user_ava}}"></img></i><i class="muiRbox"><i class="nameBox {{attKey}}Name"><i class="nameTxt">{{attName}}</i><i class="ico36 ico36Help" kn="{{attKey}}" onclick="ryo.muih(this)"></i></i><i class="valBox {{attKey}}"><input id="{{attKey}}Val" type="text" class="valTxt" kn="{{attKey}}" value="{{attVal}}" readonly onchange="ryo.na(this, \'is\', \'cg\')" /><i class="ico36 icoEd" onclick="ryo.mui(this)"></i></i></i></i>',

        qrlink: '<i class="qrlCtn">{{QR_user_qrl}}</i>',

        sect: '<i class="sectBox"><i class="userList"><img class="avaImg" src="{{ava}}" /><i class="userName">{{un}}</i><i class="userRel">{{rel}}</i></i></i>',

        bill: '',

        adv: '<i class="advCtn"></i>',
    },

};

String.prototype.ltrim = function() {
    return this.replace(/(^\s*)/g, '');
}

String.prototype.rtrim = function() {
    return this.replace(/(\s*$)/g, '');
}

try {
    var WX = wx;
} catch (e) {}